You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
在dev环境下:import style from './index.module.less' ;
{ text }
,使用正常;
在build后,index.module.less文件编译成index.module.less.js + index.module.css;
编译的js中:import r from "./index.module.less.js"; React.createElement("p", { className: r.text }, t));
样式使用异常。并被引入时,导致界面报错。
下面是我的vite.config.ts配置,希望有人能帮助我。谢谢!
export default defineConfig({
build: {
target: 'modules',
outDir: "dist",
minify: true,
cssTarget: 'chrome61',
cssCodeSplit: true,
lib: {
// 组件库源码的入口文件
entry: path.resolve(__dirname, './package/index.ts'),
formats:['es']
},
rollupOptions: {
external: ['react', 'react-dom'],
input: './package/index.ts',
output: {
format: "cjs",
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name].[ext]',
//让打包目录和我们目录对应
preserveModules: true,
exports: "named",
dir: path.resolve(__dirname, "./dist"),
//配置打包根目录
globals: {
react: 'react',
'react-dom': 'react-dom',
},
},
},
},
css: {
transformer: 'postcss',
modules: {
scopeBehaviour: 'local'
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
}
},
},
plugins: [
react({
jsxRuntime: 'classic'
}),
dts({
entryRoot: "package",
outDir: path.resolve(__dirname, "./dist"),
exclude: ['./node_modules'],
tsconfigPath: "./tsconfig.app.json",
}),
],
})
Reproduction
http://localhost:5173/
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: