forked from hql287/Manta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.parts.js
66 lines (58 loc) · 1.37 KB
/
webpack.parts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const webpack = require('webpack');
const BabelWebpackPlugin = require('babel-minify-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
exports.devServer = ({ host, port } = {}) => ({
devServer: {
hot: true,
inline: true,
progress: true,
host,
port,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
});
// Source Map
exports.generateSourceMaps = ({ type }) => ({
devtool: type,
});
// Check Duplicates
exports.checkDuplicate = (options) => ({
plugins: [
new DuplicatePackageCheckerPlugin(options),
],
});
// Clean between builds
exports.clean = (path) => ({
plugins: [
new CleanWebpackPlugin([path]),
],
});
// JS Minification
exports.minifyJavaScript = () => ({
plugins: [
new BabelWebpackPlugin(),
],
});
// Analyzing Bundle
exports.analyzeBundle = () => ({
plugins: [
new BundleAnalyzerPlugin(),
],
});
// Webpack Dashboard
exports.webpackDashboard = () => ({
plugins: [
new DashboardPlugin(),
],
});
// Extract vendor files
exports.extractBundles = bundles => ({
plugins: bundles.map((bundle) => (
new webpack.optimize.CommonsChunkPlugin(bundle)
)),
});