-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite2+vite-plugin-style-import css.preprocessorOptions.less.modifyVars定义的变量不生效 #9
Comments
vite.config.ts {
css: {
preprocessorOptions: {
less: {
modifyVars:{},
javascriptEnabled: true,
},
},
},
plugins:[{
libraryName: 'ant-design-vue',
esModule: true,
resolveStyle: (name) => {
return `ant-design-vue/es/${name}/style/index`;
},
},]
} |
这样写可以生效 |
import {
defineConfig
} from 'vite'
import {
resolve as pathResolve,
join as pathJoin
} from 'path'
import {
createVuePlugin
} from 'vite-plugin-vue2'
import vueJsx from '@vitejs/plugin-vue-jsx'
import legacy from '@vitejs/plugin-legacy'
import styleImport from 'vite-plugin-style-import'
const isProd = process.env.NODE_ENV === 'production'
export default defineConfig({
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
// hack: `true; @import "${pathResolve(__dirname, './src/less/vant.theme.less')}"`
hack: `true; @import "${pathJoin(__dirname, './src/less/vant.theme.less')}"`
}
}
}
},
resolve: {
alias: [
{
find: /^~/,
replacement: ''
},
{
find: '@',
replacement: pathResolve(__dirname, './src')
}
]
},
plugins: [
createVuePlugin({
jsxOptions: {
compositionAPI: true
}
}),
vueJsx(),
legacy({
targets: ['defaults', 'not IE 11']
}),
styleImport({
libs: [
{
libraryName: 'vant',
esModule: true,
resolveStyle: isProd
? (name) =>`vant/es/${name}/style/less`
: null
}
]
})
],
server: {
force: true
}
}) 原来是需要 |
vant2 dev prod 都可以 |
{ |
我的prod环境也是不行,请问大佬解决了吗? |
if (import.meta.env.DEV) { 如果生产环境不引入的话,好像主要主题不生效的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: