-
Notifications
You must be signed in to change notification settings - Fork 33
/
webpack.config.plugins.js
111 lines (104 loc) · 2.34 KB
/
webpack.config.plugins.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const FileManagerPlugin = require( 'filemanager-webpack-plugin' );
const NODE_ENV = process.env.NODE_ENV || 'development';
const path = require( 'path' );
defaultConfig.plugins.splice( 1, 1 ); // We need to remove Core's Copy Files plugin.
const getConfig = textdomain => {
return {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve( 'babel-loader' ),
options: {
cacheDirectory:
process.env.BABEL_CACHE_DIRECTORY || true,
babelrc: false,
configFile: false,
presets: [
require.resolve(
'@wordpress/babel-preset-default'
)
],
plugins: [
[ '@automattic/babel-plugin-replace-textdomain', { 'textdomain': textdomain }]
]
}
}
]
},
...defaultConfig.module.rules
]
};
};
const plugins = {
plugins: [
...defaultConfig.plugins,
new FileManagerPlugin({
events: {
onEnd: {
delete: [
'build/animation/blocks/',
'build/animation/pro/',
'build/css/blocks/',
'build/css/pro/',
'build/export-import/blocks/',
'build/export-import/pro/'
]
}
},
runOnceInWatchMode: false,
runTasksInSeries: true
})
]
};
module.exports = [
{
// ANIMATION
...defaultConfig,
stats: 'minimal',
mode: NODE_ENV,
entry: {
index: './src/animation/index.js',
frontend: './src/animation/frontend.js',
'anim-count': './src/animation/frontend/count/index.js',
'anim-typing': './src/animation/frontend/typing/index.js',
'welcome-notice': './src/animation/welcome-notice/index.js'
},
output: {
path: path.resolve( __dirname, './build/animation' )
},
module: { ...getConfig( 'blocks-animation' ) },
...plugins
},
{
// CSS
...defaultConfig,
stats: 'minimal',
mode: NODE_ENV,
entry: {
index: './src/css/index.js'
},
output: {
path: path.resolve( __dirname, './build/css' )
},
module: { ...getConfig( 'blocks-css' ) },
...plugins
},
{
// Export Import
...defaultConfig,
stats: 'minimal',
mode: NODE_ENV,
entry: {
index: './src/export-import/index.js'
},
output: {
path: path.resolve( __dirname, './build/export-import' )
},
module: { ...getConfig( 'blocks-export-import' ) },
...plugins
}
];