标签:ack process option res source func 引入 javascrip src
1、添加依赖 style-resources-loader
2、vue.config.js中添加
module.exports = {
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [],
},
},
};
3、添加全局less引入
module.exports = {
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [
path.resolve(__dirname, './src/assets/varibles.less'),
],
},
},
};
4、加入path
const path = require('path');
module.exports = {
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [
path.resolve(__dirname, './src/assets/varibles.less'),
],
},
},
};
const path = require('path')
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
},
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
}
}
function addStyleResource(rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, 'src/styles/variable.less'), // 需要全局导入的less
],
})
}
module.exports = {
css: {
loaderOptions: {
less: {
globalVars: {
primary: '#fff'
}
}
}
}
}
标签:ack process option res source func 引入 javascrip src
原文地址:https://www.cnblogs.com/ajaemp/p/12024106.html