美文网首页
小程序支持打包i-view 的样式做px转义

小程序支持打包i-view 的样式做px转义

作者: Axiba | 来源:发表于2019-06-03 09:43 被阅读0次

    修改 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: ['.*']
          }
        ])
      ]
    
    

    相关文章

      网友评论

          本文标题:小程序支持打包i-view 的样式做px转义

          本文链接:https://www.haomeiwen.com/subject/lwmqxctx.html