小程序支持打包i-view 的样式做px转义
2019-06-03 本文已影响0人
Axiba
修改 build/webpack.base.conf.js 文件:
// 引入依赖
const Px2rpx = require('px2rpx');
const px2rpxIns = new Px2rpx({ rpxUnit: 0.5 });
// 在plugins 中 增减 transform(...) {}
plugins: [
new MpvuePlugin(),
new MpvueEntry(),
// api 统一桥协议方案
new webpack.DefinePlugin({
'mpvue': 'global.mpvue',
'mpvuePlatform': 'global.mpvuePlatform'
}),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: path.resolve(config.build.assetsRoot, './static'),
transform(content, path) {
if (path.endsWith('.wxss')) {
return px2rpxIns.generaterpx(content.toString(), 1)
} else {
return content
}
},
ignore: ['.*']
}
])
]