Skip to content

Commit

Permalink
fix: #14 页面代码变更也会影响到vendor.js版本号
Browse files Browse the repository at this point in the history
需要在页面增加对manifest.js的引用
1.vendor.js
2.manifest.js
3.页面.js
  • Loading branch information
zhongzhi107 committed Dec 6, 2017
1 parent 8edb8db commit 54ae56e
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/config/webpack.build.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import path from 'path';
import { isFunction } from 'util';
import { yellow } from 'chalk';
import webpack from 'webpack';
import CleanPlugin from 'clean-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
Expand Down Expand Up @@ -165,15 +166,29 @@ const webpackConfig = () => {
];

// 从配置文件中获取并生成webpack打包配置
// fix: #14
let chunkNames = [];
if (commonChunks) {
const chunkKeys = Object.keys(commonChunks);
chunkKeys.forEach((key) => {
const manifestChunkName = 'manifest';
chunkNames = Object.keys(commonChunks);
const lastChunkName = chunkNames[chunkNames.length - 1];
// 确保manifest放在最后
if (lastChunkName !== manifestChunkName) {
chunkNames.push(manifestChunkName);
}
// 检测chunk配置的有效性
const index = chunkNames.indexOf(manifestChunkName);
if (index !== chunkNames.length - 1) {
// manifest位置不对时,校正配置并给出提示
chunkNames.splice(index, 1);
console.log(yellow('⚠️ There is a problem with the manifest package configuration. Packing has automatically repaired the error configuration'));
}
chunkNames.filter(name => name !== manifestChunkName).forEach((key) => {
entry[key] = commonChunks[key];
});

// 扩展阅读 http://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
plugins.push(new webpack.optimize.CommonsChunkPlugin({ names: chunkKeys }));
}
// 扩展阅读 http://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
plugins.push(new webpack.optimize.CommonsChunkPlugin({ names: chunkNames }));

if (minimize) {
plugins.push(
Expand Down

0 comments on commit 54ae56e

Please sign in to comment.