-
Notifications
You must be signed in to change notification settings - Fork 476
/
webpack.parts.js
41 lines (35 loc) · 1 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
const webpack = require('webpack');
const BabelWebpackPlugin = require('babel-minify-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-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()],
});