taro
taro copied to clipboard
taro3如何全局注入less
taro3如何全局注入less
试了两种方法都没生效 options.less
@theme-color: #07c160;
webpackChain (chain, webpack) {
//方法1
chain.module.rule('less').use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, 'src/assets/styles/options.less')
],
// injector: 'append'
})
//方法2
// chain.merge({
// module: {
// rule: {
// less: {
// test: /\.less$/,
// use: [{
// loader: 'style-resources-loader',
// options: {
// patterns: [path.resolve(__dirname, './src/assets/styles/options.less')],
// injector: 'append'
// }
// }]
// }
// }
// }
// })
}
编译报错
color: fade(@theme-color, 50);
^
Error evaluating function `fade`: variable @theme-color is undefined
@LiangFuzhi 解决了吗?
@LiangFuzhi 解决了吗?
转用uniapp了
webpackChain(chain, webpack) {
chain.module
.rule("less")
.oneOf("0") // 小程序平台需要这个,h5平台这行去掉
.use("style-resource")
.loader("style-resources-loader")
.options({
patterns: [path.resolve(__dirname, "..", "src/styles/index.less")]
// injector: 'append'
});
}
@Binbiubiubiu 用了还是不行
@rgz665 https://github.com/Binbiubiubiu/taro-plugin-style-resource
@rgz665 https://github.com/Binbiubiubiu/taro-plugin-style-resource
"@tarojs/taro": "3.6.23",没用
@rgz665 https://github.com/Binbiubiubiu/taro-plugin-style-resource
"@tarojs/taro": "3.6.23",没用
试过可以,使用的是NutUI-v4