-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
64 lines (59 loc) · 1.51 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require( 'path' )
const pckg = require( './package.json' )
const CssMinimizerPlugin = require( 'css-minimizer-webpack-plugin' )
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' )
const alias = {}
// Build config.
const config = {
mode: 'development',
entry: './src/index.js',
externals: {
/**
* These external references provide nice import shortcuts for the libraries already
* provided by either WordPress itself or Assistant.
* This ensures you're using the same copy as Assistant and react contexts work properly.
*/
'react': 'React',
'@wordpress/i18n' : 'wp.i18n',
/* Assistant-provided vendor libraries */
'react-router-dom': 'ReactRouterDOM',
'framer-motion': 'FramerMotion',
'redux': 'Redux',
/* Assistant API */
'assistant': 'FL.Assistant',
'assistant/ui': 'FL.Assistant.ui',
'assistant/data': 'FL.Assistant.data',
},
output: {
path: path.resolve( __dirname, 'build' ),
filename: '[name].js',
chunkFilename: `chunk-[name].js?var=${ pckg.version }`
},
resolve: { alias },
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [ 'babel-loader' ]
},
{
test: /\.s?css$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader' ],
},
]
},
plugins: [
new MiniCssExtractPlugin( {
filename: '[name].css',
} )
],
}
// Production build config.
if ( 'production' === process.env.NODE_ENV ) {
config.optimization = {
minimize: true,
minimizer: [ new CssMinimizerPlugin() ]
}
}
module.exports = config