weex笔记(1)weex提升编译速度

523 阅读1分钟

每次weex编译都会卡在asset optimization 94%

最新新版本weex-toolkit 脚手架会不会有这问题。

老版本需要做如下修改

webpack.dev.conf.js 文件中修改html-webpack-plugin为html-webpack-plugin-for-multihtml

const HtmlWebpackPlugin = require('html-webpack-plugin-for-multihtml');

并在声明HtmlWebpackPlugin的地方加上multihtmlCache: true

const generateHtmlWebpackPlugin = (entry) => {
  let entrys = Object.keys(entry);
  // exclude vendor entry.
  entrys = entrys.filter(entry => entry !== 'vendor' );
  const htmlPlugin = entrys.map(name => {
    return new HtmlWebpackPlugin({
      multihtmlCache: true,
      filename: name + '.html',
      template: helper.rootNode(`web/index.html`),
      isDevServer: true,
      chunksSortMode: 'dependency',
      inject: true,
      devScripts: config.dev.htmlOptions.devScripts,
      chunks: ['vendor', name]
    })
  })
  return htmlPlugin;
}

最后安装一下新module html-webpack-plugin-for-multihtml 在工程根目录npm install html-webpack-plugin-for-multihtml