generated from luehrsenheinrich/wp-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
executable file
·48 lines (47 loc) · 1.03 KB
/
webpack.config.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
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
const glob = require('glob');
module.exports = {
entry: glob.sync('./build/js/*.js').reduce(function (obj, el) {
obj[path.parse(el).name + '.min'] = el;
obj[path.parse(el).name + '.bundle'] = el;
return obj;
}, {}),
mode: 'none',
output: {
path: path.resolve(__dirname, './trunk/js'),
filename: '[name].js',
},
plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
wp: 'wp',
}),
new TerserPlugin({
include: /\.min\.js$/,
}),
new DependencyExtractionWebpackPlugin(),
],
externals: {
jquery: 'jQuery',
wp: 'wp',
react: 'React',
'react-dom': 'ReactDOM',
},
resolve: {
modules: ['node_modules'],
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
include: path.resolve(__dirname, 'build'),
},
],
},
};