forked from eventespresso/event-espresso-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
56 lines (56 loc) · 1.48 KB
/
webpack.dev.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
const merge = require( 'webpack-merge' );
const WebpackAssetsManifest = require( 'webpack-assets-manifest' );
const path = require( 'path' );
const webpack = require( 'webpack' );
const common = require( './webpack.common.js' );
const miniExtract = require( 'mini-css-extract-plugin' );
const assetsData = Object.create( null );
const DependencyExtractionWebpackPlugin = require(
'@wordpress/dependency-extraction-webpack-plugin'
);
const { requestToExternal, requestToHandle } = require(
'./bin/asset-dependency-maps'
);
const pluginsConfigWithExternals = [
new webpack.ProvidePlugin( {
React: 'react',
} ),
new DependencyExtractionWebpackPlugin( {
requestToExternal,
requestToHandle,
} ),
new WebpackAssetsManifest( {
output: path.resolve( __dirname,
'assets/dist/build-manifest.json',
),
assets: assetsData,
} ),
new miniExtract( {
filename: '[name].[contenthash].dist.css',
} ),
];
const pluginsConfigWithoutExternals = [
new WebpackAssetsManifest( {
output: path.resolve( __dirname,
'assets/dist/build-manifest.json',
),
assets: assetsData,
} ),
new webpack.ProvidePlugin( {
React: 'react',
} ),
new miniExtract( {
filename: '[name].[contenthash].dist.css',
} ),
];
common.forEach( ( config, index ) => {
const plugins = config.entry[ 'eventespresso-vendor' ] ?
pluginsConfigWithoutExternals :
pluginsConfigWithExternals;
common[ index ] = merge( config, {
devtool: 'inline-source-map',
plugins,
mode: 'development',
} );
} );
module.exports = common;