Skip to content

Commit 6e2fc40

Browse files
authored
Fix: The build script [ED-14943] (#409)
1 parent 60c740b commit 6e2fc40

4 files changed

Lines changed: 31 additions & 50 deletions

File tree

.buildignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*.zip
2+
karma.conf.js
3+
assets/dev/
4+
assets/scss/
5+
assets/js/qunit-tests*
6+
bin/
7+
build/
8+
composer.json
9+
composer.lock
10+
Gruntfile.js
11+
node_modules/
12+
npm-debug.log
13+
package-lock.json
14+
package.json
15+
phpcs.xml
16+
README.md
17+
webpack.config.js
18+
vendor/
19+
20+
.github/
21+
.buildignore
22+
.editorconfig
23+
.gitignore
24+
.browserslistrc
25+
.eslintignore
26+
.eslintrc.js

Gruntfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function( grunt ) {
2121
expand: true,
2222
cwd: 'assets/scss',
2323
src: '*.scss',
24-
dest: './build',
24+
dest: './',
2525
ext: '.css',
2626
} ] : [ {
2727
expand: true,
@@ -62,8 +62,8 @@ module.exports = function( grunt ) {
6262
files: [ {
6363
expand: true,
6464
src: 'production' === grunt.option( 'environment' ) ? [
65-
'build/*.css',
66-
'!build/*.min.css',
65+
'*.css',
66+
'!*.min.css',
6767
] : [
6868
'*.css',
6969
'!*.min.css',

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build:dev": "concurrently \"grunt default\" \"webpack --env=development\"",
1212
"build:dev:watch": "concurrently \"grunt default watch\" \"webpack --env=developmentLocal\"",
1313
"clean:build": "rimraf build && rimraf hello-elementor",
14-
"zip": "npm run clean:build && npm run build:prod && mv build hello-elementor && zip -r hello-elementor.$npm_package_version.zip hello-elementor/*",
14+
"zip": "npm run clean:build && npm run build:prod && rsync -av --exclude-from=.buildignore . hello-elementor && zip -r hello-elementor.$npm_package_version.zip hello-elementor/*",
1515
"lint:js": "eslint ."
1616
},
1717
"devDependencies": {
@@ -28,7 +28,6 @@
2828
"babel-eslint": "^8.2.6",
2929
"babel-loader": "8.0.0",
3030
"concurrently": "^6.2.0",
31-
"copy-webpack-plugin": "^9.0.0",
3231
"cssnano": "4.1.11",
3332
"eslint": "8.36.0",
3433
"eslint-config-wordpress": "^2.0.0",

webpack.config.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
const path = require( 'path' );
77
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
88

9-
const CopyPlugin = require( 'copy-webpack-plugin' );
109
const TerserPlugin = require( 'terser-webpack-plugin' );
1110

1211
const entry = {
@@ -15,43 +14,6 @@ const entry = {
1514
'hello-admin': path.resolve( __dirname, './assets/dev/js/admin/hello-admin.js' ),
1615
};
1716

18-
const copyPluginConfig = new CopyPlugin( {
19-
patterns: [
20-
{
21-
from: '**/*',
22-
context: __dirname,
23-
to: path.resolve( __dirname, 'build' ),
24-
// Terser skip this file for minimization
25-
info: { minimized: true },
26-
globOptions: {
27-
ignore: [
28-
// ignore minified php files
29-
...Object.keys( entry ).map( ( key ) => `**/assets/js/${ key }.min.asset.php` ),
30-
'**.zip',
31-
'**.css',
32-
'**/karma.conf.js',
33-
'**/assets/dev/**',
34-
'**/assets/scss/**',
35-
'**/assets/js/qunit-tests*',
36-
'**/bin/**',
37-
'**/build/**',
38-
'**/composer.json',
39-
'**/composer.lock',
40-
'**/Gruntfile.js',
41-
'**/node_modules/**',
42-
'**/npm-debug.log',
43-
'**/package-lock.json',
44-
'**/package.json',
45-
'**/phpcs.xml',
46-
'**/README.md',
47-
'**/webpack.config.js',
48-
'**/vendor/**',
49-
],
50-
},
51-
},
52-
],
53-
} );
54-
5517
const moduleRules = {
5618
rules: [
5719
...defaultConfig.module.rules,
@@ -125,13 +87,7 @@ Object.entries( webpackProductionConfig.entry ).forEach( ( [ wpEntry, value ] )
12587
webpackProductionConfig.entry[ wpEntry + '.min' ] = value;
12688
} );
12789

128-
// Override copyPluginConfig
129-
// we first remove the one supplied by @wordpress/scripts
130-
webpackProductionConfig.plugins = webpackProductionConfig.plugins.filter( ( plugin ) => {
131-
return plugin.constructor.name !== 'CopyPlugin';
132-
} );
133-
// then we add our own
134-
webpackProductionConfig.plugins = [ copyPluginConfig, ...defaultConfig.plugins ];
90+
webpackProductionConfig.plugins = defaultConfig.plugins;
13591

13692
module.exports = ( env ) => {
13793
if ( env.developmentLocal ) {

0 commit comments

Comments
 (0)