Skip to content

Commit

Permalink
refactor: extend instead of replacing, relative ant-tool/atool-build#264
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredleechn committed Apr 17, 2017
1 parent dbc3775 commit 573b6aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"peerDependencies": {
"atool-build": "~0.7.0",
"atool-build": "~0.9.4",
"dora": "~0.3.0"
},
"dependencies": {
Expand Down
40 changes: 18 additions & 22 deletions src/getWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import path, { join } from 'path';
import { existsSync } from 'fs';
import getWebpackCommonConfig from 'atool-build/lib/getWebpackCommonConfig';
import mergeCustomConfig from 'atool-build/lib/mergeCustomConfig';
import webpack, { ProgressPlugin } from 'atool-build/lib/webpack';
import { ProgressPlugin } from 'atool-build/lib/webpack';
import { ExtractTextPlugin } from 'atool-build/lib/dependencies';
import glob from 'glob';
import Copy from 'copy-webpack-plugin';
import Index from './index-webpack-plugin';
Expand Down Expand Up @@ -110,27 +111,22 @@ export default function (source, asset, dest, cwd, tpl, config) {
link[path.relative(source, key)] = key;
});

webpackConfig.plugins = [
new ProgressPlugin((percentage, msg) => {
const stream = process.stderr;
if (stream.isTTY && percentage < 0.71) {
stream.cursorTo(0);
stream.write(`📦 ${msg}`);
stream.clearLine(1);
} else if (percentage === 1) {
console.log('\nwebpack: bundle build is now finished.');
}
}),
new webpack.optimize.CommonsChunkPlugin('common', 'common.js'),
new webpack.optimize.OccurenceOrderPlugin(),
new Copy([{ from: asset, to: asset }]),
new Index({
params: {
link,
},
title: 'title',
}),
];
webpackConfig.plugins = webpackConfig.plugins
.filter(plugin => !(plugin instanceof ExtractTextPlugin))
.concat(
new ProgressPlugin((percentage, msg) => {
const stream = process.stderr;
if (stream.isTTY && percentage < 0.71) {
stream.cursorTo(0);
stream.write(`📦 ${msg}`);
stream.clearLine(1);
} else if (percentage === 1) {
console.log('\nwebpack: bundle build is now finished.');
}
}),
new Copy([{ from: asset, to: asset }]),
new Index({ params: { link }, title: 'title' }),
);
webpackConfig.externals = {};
return webpackConfig;
}

0 comments on commit 573b6aa

Please sign in to comment.