-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
70 lines (60 loc) · 2.68 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
65
66
67
68
69
70
// WordPress webpack config.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
// Plugins.
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
// Utilities.
const path = require( 'path' );
const imagesPath = path.resolve( __dirname, './build/images' );
const modulesDir = process.cwd() + '/modules/';
const entryPoints = {
// Admin module:
'js/helloplus-onboarding': path.resolve( modulesDir, 'admin/assets/js', 'hello-plus-onboarding.js' ),
// Content module
'css/helloplus-zigzag': path.resolve( modulesDir, 'content/assets/scss', 'hello-plus-zigzag.scss' ),
'css/helloplus-hero': path.resolve( modulesDir, 'content/assets/scss', 'hello-plus-hero.scss' ),
'css/helloplus-cta': path.resolve( modulesDir, 'content/assets/scss', 'hello-plus-cta.scss' ),
'css/helloplus-flex-hero': path.resolve( modulesDir, 'content/assets/scss', 'hello-plus-flex-hero.scss' ),
'js/helloplus-zigzag-fe': path.resolve( modulesDir, 'content/assets/js/frontend', 'hello-plus-zigzag-fe.js' ),
// Template Parts module
'css/helloplus-template-parts-preview': path.resolve( modulesDir, 'template-parts/assets/scss', 'hello-plus-template-parts-preview.scss' ),
'css/helloplus-header': path.resolve( modulesDir, 'template-parts/assets/scss', 'hello-plus-header.scss' ),
'css/helloplus-footer': path.resolve( modulesDir, 'template-parts/assets/scss', 'hello-plus-footer.scss' ),
'js/helloplus-header': path.resolve( modulesDir, 'template-parts/assets/js', 'hello-plus-header.js' ),
'js/helloplus-editor': path.resolve( modulesDir, 'template-parts/assets/js', 'editor.js' ),
// Forms module
'css/helloplus-forms': path.resolve( modulesDir, 'forms/assets/scss/widgets', 'hello-plus-forms.scss' ),
'js/helloplus-forms-editor': path.resolve( modulesDir, 'forms/assets/js', 'editor.js' ),
'js/helloplus-forms-editor-fe': path.resolve( modulesDir, 'forms/assets/js/frontend', 'frontend.js' ),
};
module.exports = {
...defaultConfig,
...{
entry: entryPoints,
output: {
...defaultConfig.output,
path: path.resolve( __dirname, './build' ),
},
plugins: [
// Include WP's plugin config.
...defaultConfig.plugins,
new CopyWebpackPlugin( {
patterns: [
{
from: path.resolve( modulesDir, 'forms/assets/images' ),
to: imagesPath,
},
{
from: path.resolve( modulesDir, 'template-parts/assets/images' ),
to: imagesPath,
},
],
} ),
// Removes the empty `.js` files generated by webpack but
// sets it after WP has generated its `*.asset.php` file.
new RemoveEmptyScriptsPlugin( {
stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
} ),
],
},
};