dvajs / dva-example-user-dashboard

👲 👬 👨‍👩‍👧 👨‍👩‍👦‍👦
446 stars 205 forks source link

按需加载css提取问题 #18

Closed flicker85 closed 7 years ago

flicker85 commented 7 years ago

执行build,indexPage和Users打包出的js文件中存在大量的 .ant-menu-... 等样式代码,请问如何把这些重复的代码提取到index.css中? 以前在webpack中是用ExtractTextPlugin提取,请问在dva roadhog中应该怎么配置?

flicker85 commented 7 years ago

还有,如果想把打包出的js文件中重复的Menu组件代码也提取出来应该怎么写? 以前在webpack中是使用CommonsChunkPlugin提取。

flicker85 commented 7 years ago

已解决

zhangjingge commented 7 years ago

@flicker85 可以说一下解决方法吗?目前也想使用这种方法

flicker85 commented 7 years ago

@zhangjingge https://github.com/sorrycc/roadhog

module.exports = function (webpackConfig, env) {
  if (env === 'production') {
    webpackConfig.plugins.forEach(plugin => {
      if(plugin.filename && plugin.filename === "[name].css") {
        plugin.options && (plugin.options.allChunks = true);
      }
    });
  }
  return webpackConfig;
}
zhangjingge commented 7 years ago

@flicker85 灰常感谢