配置vue插件 lib-flexible
1.安裝插件 lib-flexible
npm i lib-flexible --save-dev
2.在main.js中引入lib-flexible
import 'lib-flexible/flexible'
3.安裝px2rem loader
npm install px2rem-loader --save-dev
4.配置px2rem-loader
在build文件中找到util.js葛峻,將px2rem-loader添加到cssLoaders中缩焦,如:
const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
sourceMap: options.sourceMap
}
}
const px2remLoader = {
loader: 'px2rem-loader',
options: {
remUnit: 75
}
}
同時塑顺,在generateLoaders方法中添加px2remLoader
function generateLoaders (loader, loaderOptions) {
const loaders = [cssLoader,px2remLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}