-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathwebpack.config.js
More file actions
63 lines (57 loc) · 2.36 KB
/
webpack.config.js
File metadata and controls
63 lines (57 loc) · 2.36 KB
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
// WordPress webpack config:
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
//Plugins:
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
//Utilities
const path = require( 'path' );
const imagesPath = path.resolve( __dirname, './assets/images' );
const modulesDir = process.cwd() + '/modules/';
const entryPoints = {
'css/reset': path.resolve( __dirname, './dev/scss', 'reset.scss' ),
'css/theme': path.resolve( __dirname, './dev/scss', 'theme.scss' ),
'css/header-footer': path.resolve( __dirname, './dev/scss', 'header-footer.scss' ),
'css/editor-styles': path.resolve( __dirname, './dev/scss', 'editor-styles.scss' ),
'css/editor': path.resolve( __dirname, './dev/scss', 'editor.scss' ),
'css/customizer': path.resolve( __dirname, './dev/scss', 'customizer.scss' ),
'js/hello-editor': path.resolve( __dirname, './dev/js/editor', 'hello-editor.js' ),
'js/hello-frontend': path.resolve( __dirname, './dev/js/frontend', 'hello-frontend.js' ),
'js/hello-home-app': path.resolve( modulesDir, 'admin-home/assets/js', 'hello-elementor-admin.js' ),
'js/hello-elementor-menu': path.resolve( modulesDir, 'admin-home/assets/js', 'hello-elementor-menu.js' ),
'js/hello-elementor-settings': path.resolve( modulesDir, 'admin-home/assets/js', 'hello-elementor-settings.js' ),
'js/hello-elementor-topbar': path.resolve( modulesDir, 'admin-home/assets/js', 'hello-elementor-topbar.js' ),
'js/hello-conversion-banner': path.resolve( modulesDir, 'admin-home/assets/js', 'hello-elementor-conversion-banner.js' ),
};
module.exports = {
...defaultConfig,
...{
entry: entryPoints,
output: {
...defaultConfig.output,
path: path.resolve( __dirname, './assets' ),
chunkFilename: 'js/[name].js',
clean: false,
},
plugins: [
// Include WP's plugin config.
...defaultConfig.plugins,
new CopyWebpackPlugin( {
patterns: [
{
from: path.resolve( modulesDir, 'admin-home/assets/images' ),
to: imagesPath,
},
{
from: path.resolve( __dirname, 'dev/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,
} ),
],
},
};