Closed yoonasy closed 3 years ago
relative path to scss is work. @import "src/assets/styles/vars.scss";
so i think less
import path is also like this
it work if you config like this
@Wushq ok, thank u, but still no substitution variable
modifyVars: {
hack: `true; @import "${join(
__dirname,
'./src/assets/styles/themes/vant.theme.var.less'
)}";`,
},
"vite": "^1.0.0-rc.9", "less": "^3.12.2", "sass": "^1.29.0", "vue": "^3.0.2", "vite-plugin-html": "^1.0.0-beta.2", "vite-plugin-mock": "^1.0.6", "vite-plugin-purge-icons": "^0.4.4", "vite-plugin-pwa": "^0.1.3",
I will try again
Oh, sor, I found the problem, I dated multiple compiled css
files
import 'vant/lib/index.css'
@Wushq hi, How do you import vant Less on demand
it work if you config like this
i did the same but its still not working.
Has this problem been solved? I don't see a credible result
Done like this (Vite 2.x):
export default defineConfig({
// ...
css: {
preprocessorOptions: {
less: {
modifyVars: { 'primary-color': '#13c2c2' },
javascriptEnabled: true,
},
},
},
});
See more about my config pinyin/vite.config.ts
CC @ShookLyngs @lixianyu-icon
` // 第零步 在assets下创建/less/overwrite/overwrite.less
// 第一步 import { resolve } from 'path';
// 第二步 function pathResolve(dir: string) { return resolve(__dirname, '.', dir); }
// 第三步
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: true; @import "${resolve( './src/assets/less/overwrite/overwrite.less' )}";
,
}
, javascriptEnabled: true
}
}
},
`
Describe the bug
this is modify to vantUI theme variable. less import not work.
vant.theme.var.less
In this
less options
, no work,invue.config.js
is work.Reproduction
Please provide a link to a repo that can reproduce the problem you ran into.
A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.
System Info
vite
version:vite v1.0.0-rc.9vue
version (fromyarn.lock
orpackage-lock.json
)@vue/compiler-sfc
versionLogs (Optional if provided reproduction)
vite
orvite build
with the--debug
flag.