wp-blank-scripts 2.7.0 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/.eslintrc.js +0 -1
- package/config/.eslintrc.react.js +0 -1
- package/lib/buildProject.js +21 -6
- package/lib/index.js +0 -0
- package/overridable/index.js +0 -0
- package/package.json +51 -59
- package/webpack.base.config.js +45 -45
- package/webpack.wp.config.js +0 -7
- package/utils/babelConfig.js +0 -52
package/config/.eslintrc.js
CHANGED
package/lib/buildProject.js
CHANGED
|
@@ -2,7 +2,7 @@ const chalk = require('chalk');
|
|
|
2
2
|
const opn = require('opn');
|
|
3
3
|
const rimraf = require('rimraf');
|
|
4
4
|
const webpack = require('webpack');
|
|
5
|
-
const merge = require('webpack-merge');
|
|
5
|
+
const { merge } = require('webpack-merge');
|
|
6
6
|
const webpackDevMiddleware = require('webpack-dev-middleware');
|
|
7
7
|
const webpackHotMiddleware = require('webpack-hot-middleware');
|
|
8
8
|
const browserSync = require('browser-sync');
|
|
@@ -82,13 +82,28 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
82
82
|
|
|
83
83
|
rimraf.sync('dist');
|
|
84
84
|
|
|
85
|
-
const config = merge
|
|
85
|
+
const config = merge(...[baseConfig, envConfig, buildConfig, webpackConfig].filter(Boolean));
|
|
86
86
|
|
|
87
87
|
if (options.isDev) {
|
|
88
88
|
const settings = getSettings();
|
|
89
89
|
const url = settings.url[options.environment];
|
|
90
90
|
|
|
91
|
-
const compiler = webpack(config)
|
|
91
|
+
const compiler = webpack(config, (err) => {
|
|
92
|
+
if (err) {
|
|
93
|
+
logger.error(err.stack || err);
|
|
94
|
+
|
|
95
|
+
if (err.details) {
|
|
96
|
+
logger.error(err.details);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (failOnError) {
|
|
100
|
+
exitWithError();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
92
107
|
const devMiddleware = webpackDevMiddleware(compiler, {
|
|
93
108
|
publicPath: config.output.publicPath,
|
|
94
109
|
stats: {
|
|
@@ -97,8 +112,8 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
97
112
|
warnings: true,
|
|
98
113
|
},
|
|
99
114
|
writeToDisk: true,
|
|
100
|
-
logger,
|
|
101
115
|
});
|
|
116
|
+
|
|
102
117
|
const hotMiddleware = webpackHotMiddleware(compiler);
|
|
103
118
|
|
|
104
119
|
browserSync({
|
|
@@ -145,11 +160,11 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
145
160
|
const info = stats.toJson();
|
|
146
161
|
|
|
147
162
|
if (stats.hasWarnings()) {
|
|
148
|
-
info.warnings.forEach(warning => logger.warn(warning));
|
|
163
|
+
info.warnings.forEach((warning) => logger.warn(warning));
|
|
149
164
|
}
|
|
150
165
|
|
|
151
166
|
if (stats.hasErrors()) {
|
|
152
|
-
info.errors.forEach(error => {
|
|
167
|
+
info.errors.forEach((error) => {
|
|
153
168
|
logger.error(chalk.red(error));
|
|
154
169
|
});
|
|
155
170
|
|
package/lib/index.js
CHANGED
|
File without changes
|
package/overridable/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wp-blank-scripts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "Personal Wordpress Scripts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,73 +31,65 @@
|
|
|
31
31
|
"author": "ViVO Digital",
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"dependencies": {
|
|
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
|
-
"file-loader": "^6.0.0",
|
|
61
|
-
"get-port": "^4.1.0",
|
|
62
|
-
"glob": "^7.1.1",
|
|
63
|
-
"html-webpack-plugin": "^4.3.0",
|
|
64
|
-
"husky": "^3.0.5",
|
|
65
|
-
"inquirer": "^3.0.4",
|
|
66
|
-
"lint-staged": "^9.2.5",
|
|
67
|
-
"mini-css-extract-plugin": "^0.9.0",
|
|
68
|
-
"mysql": "^2.13.0",
|
|
34
|
+
"@hot-loader/react-dom": "^17.0.2",
|
|
35
|
+
"@prettier/plugin-php": "^0.19.6",
|
|
36
|
+
"browser-sync": "^2.29.3",
|
|
37
|
+
"chalk": "4.1.2",
|
|
38
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
39
|
+
"core-js": "^3.31.0",
|
|
40
|
+
"css-loader": "^6.8.1",
|
|
41
|
+
"cssnano": "^6.0.1",
|
|
42
|
+
"esbuild-loader": "^3.0.1",
|
|
43
|
+
"eslint": "^8.42.0",
|
|
44
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
45
|
+
"eslint-config-prettier": "^8.8.0",
|
|
46
|
+
"eslint-import-resolver-node": "^0.3.7",
|
|
47
|
+
"eslint-plugin-import": "^2.27.5",
|
|
48
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
49
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
50
|
+
"eslint-plugin-react": "^7.32.2",
|
|
51
|
+
"file-loader": "^6.2.0",
|
|
52
|
+
"get-port": "5.1.1",
|
|
53
|
+
"glob": "^10.2.7",
|
|
54
|
+
"html-webpack-plugin": "^5.5.3",
|
|
55
|
+
"husky": "^8.0.3",
|
|
56
|
+
"inquirer": "3.0.4",
|
|
57
|
+
"lint-staged": "^13.2.2",
|
|
58
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
59
|
+
"mysql": "^2.18.1",
|
|
69
60
|
"node-fetch": "2",
|
|
70
|
-
"node-sass": "^4.14.1",
|
|
71
61
|
"normalize.css": "^8.0.1",
|
|
72
62
|
"opn": "^6.0.0",
|
|
73
|
-
"ora": "^
|
|
74
|
-
"postcss
|
|
75
|
-
"postcss-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
63
|
+
"ora": "^5.4.1",
|
|
64
|
+
"postcss": "^8.4.24",
|
|
65
|
+
"postcss-loader": "^7.3.3",
|
|
66
|
+
"postcss-preset-env": "^8.5.0",
|
|
67
|
+
"prettier": "^2.8.8",
|
|
68
|
+
"raw-loader": "^4.0.2",
|
|
69
|
+
"react-hot-loader": "^4.13.1",
|
|
70
|
+
"replace-in-file": "^7.0.1",
|
|
71
|
+
"rimraf": "^5.0.1",
|
|
81
72
|
"rsync": "^0.6.1",
|
|
82
|
-
"sass
|
|
83
|
-
"sass-
|
|
84
|
-
"
|
|
85
|
-
"
|
|
73
|
+
"sass": "^1.63.4",
|
|
74
|
+
"sass-loader": "^13.3.2",
|
|
75
|
+
"sass-resources-loader": "^2.2.5",
|
|
76
|
+
"semver": "^7.5.2",
|
|
77
|
+
"slugify": "^1.6.6",
|
|
86
78
|
"ssh2": "0.8.9",
|
|
87
|
-
"style-loader": "^
|
|
79
|
+
"style-loader": "^3.3.3",
|
|
88
80
|
"tempy": "^0.2.1",
|
|
89
|
-
"terser-webpack-plugin": "^
|
|
90
|
-
"time-fix-plugin": "^2.0.
|
|
91
|
-
"webpack": "^
|
|
92
|
-
"webpack-dev-middleware": "^
|
|
93
|
-
"webpack-
|
|
94
|
-
"webpack-
|
|
95
|
-
"webpack-
|
|
96
|
-
"yargs": "^
|
|
81
|
+
"terser-webpack-plugin": "^5.3.9",
|
|
82
|
+
"time-fix-plugin": "^2.0.7",
|
|
83
|
+
"webpack": "^5.87.0",
|
|
84
|
+
"webpack-dev-middleware": "^6.1.1",
|
|
85
|
+
"webpack-hot-middleware": "^2.25.3",
|
|
86
|
+
"webpack-merge": "^5.9.0",
|
|
87
|
+
"webpack-remove-empty-scripts": "^1.0.3",
|
|
88
|
+
"yargs": "^17.7.2"
|
|
97
89
|
},
|
|
98
90
|
"devDependencies": {
|
|
99
91
|
"eslint-plugin-import": "^2.14.0",
|
|
100
92
|
"eslint-plugin-jsx-a11y": "^6.1.2",
|
|
101
|
-
"eslint-plugin-node": "^
|
|
93
|
+
"eslint-plugin-node": "^11.1.0"
|
|
102
94
|
}
|
|
103
95
|
}
|
package/webpack.base.config.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const CopyPlugin = require('copy-webpack-plugin');
|
|
5
|
+
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
6
6
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
7
7
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
8
8
|
const TimeFixPlugin = require('time-fix-plugin');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
9
|
const cssnano = require('cssnano');
|
|
11
10
|
const glob = require('glob');
|
|
12
11
|
const postcssPresetEnv = require('postcss-preset-env');
|
|
@@ -14,7 +13,6 @@ const postcssPresetEnv = require('postcss-preset-env');
|
|
|
14
13
|
const logger = require('./logger');
|
|
15
14
|
const { copyFiles, copyFx, loaderOptions } = require('./overridable');
|
|
16
15
|
|
|
17
|
-
const babelConfig = require('./utils/babelConfig');
|
|
18
16
|
const getEnvironmentFile = require('./utils/getEnvironmentFile');
|
|
19
17
|
const getSettings = require('./utils/projectSettings');
|
|
20
18
|
const getFxFiles = require('./utils/getFxFiles');
|
|
@@ -51,16 +49,18 @@ function makeBaseConfig(options) {
|
|
|
51
49
|
{
|
|
52
50
|
from: path.join(sourceDir, 'assets', 'img'),
|
|
53
51
|
to: path.join(themePath, 'assets', 'img'),
|
|
52
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
54
53
|
},
|
|
55
54
|
{
|
|
56
55
|
from: path.join(sourceDir, 'assets', 'fonts'),
|
|
57
56
|
to: path.join(themePath, 'assets', 'fonts'),
|
|
57
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
|
-
from: path.join(sourceDir, 'templates'
|
|
60
|
+
from: path.join(sourceDir, 'templates'),
|
|
61
61
|
to: themePath,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
globOptions: {
|
|
63
|
+
ignore: ['.DS_Store'],
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
{
|
|
@@ -73,11 +73,13 @@ function makeBaseConfig(options) {
|
|
|
73
73
|
}
|
|
74
74
|
return contentBuffer;
|
|
75
75
|
},
|
|
76
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
76
77
|
},
|
|
77
78
|
...fxFiles.copy.map(({ context, from, to }) => ({
|
|
78
79
|
from,
|
|
79
80
|
to: path.join(themePath, 'inc', to),
|
|
80
81
|
context,
|
|
82
|
+
globOptions: { ignore: ['.DS_Store'] },
|
|
81
83
|
})),
|
|
82
84
|
];
|
|
83
85
|
|
|
@@ -85,27 +87,25 @@ function makeBaseConfig(options) {
|
|
|
85
87
|
path.join('config', 'wp-config.php'),
|
|
86
88
|
path.join('config', 'robots.txt'),
|
|
87
89
|
path.join('config', '.htaccess'),
|
|
88
|
-
].map(filePath => getEnvironmentFile(filePath, environment));
|
|
90
|
+
].map((filePath) => getEnvironmentFile(filePath, environment));
|
|
89
91
|
|
|
90
92
|
const wordpressFiles = [
|
|
91
93
|
{
|
|
92
|
-
from:
|
|
94
|
+
from: 'wordpress',
|
|
93
95
|
to: '',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
globOptions: {
|
|
97
|
+
ignore: [
|
|
98
|
+
'**/wp-content/themes/**/*',
|
|
99
|
+
'**/wp-content/plugins/hello.php',
|
|
100
|
+
'**/wp-content/plugins/akismet/**/*',
|
|
101
|
+
'.DS_Store',
|
|
102
|
+
'composer.json',
|
|
103
|
+
'readme.html',
|
|
104
|
+
'license.txt',
|
|
105
|
+
],
|
|
103
106
|
},
|
|
104
107
|
},
|
|
105
|
-
{
|
|
106
|
-
from: 'wp-content',
|
|
107
|
-
to: 'wp-content',
|
|
108
|
-
},
|
|
108
|
+
{ from: 'wp-content', to: 'wp-content' },
|
|
109
109
|
];
|
|
110
110
|
|
|
111
111
|
let customFiles = [];
|
|
@@ -155,7 +155,7 @@ function makeBaseConfig(options) {
|
|
|
155
155
|
},
|
|
156
156
|
output: {
|
|
157
157
|
path: buildPath,
|
|
158
|
-
filename: chunkData => {
|
|
158
|
+
filename: (chunkData) => {
|
|
159
159
|
const name = chunkData.chunk.name === 'adminScripts' ? 'admin' : chunkData.chunk.name;
|
|
160
160
|
return path.join(themeDir, 'assets', 'js', `${name}.js`);
|
|
161
161
|
},
|
|
@@ -167,11 +167,16 @@ function makeBaseConfig(options) {
|
|
|
167
167
|
module: {
|
|
168
168
|
rules: [
|
|
169
169
|
{
|
|
170
|
-
test: /\.
|
|
170
|
+
test: /\.[jt]sx?$/,
|
|
171
171
|
exclude: /node_modules\/(?!(dom7|swiper)\/)/,
|
|
172
172
|
use: {
|
|
173
|
-
loader: '
|
|
174
|
-
options:
|
|
173
|
+
loader: 'esbuild-loader',
|
|
174
|
+
options: {
|
|
175
|
+
loader: 'jsx',
|
|
176
|
+
// TODO: Remove in react build
|
|
177
|
+
jsxFactory: 'wp.element.createElement',
|
|
178
|
+
target: 'es2015',
|
|
179
|
+
},
|
|
175
180
|
},
|
|
176
181
|
...loaderOverrides.js,
|
|
177
182
|
},
|
|
@@ -191,12 +196,13 @@ function makeBaseConfig(options) {
|
|
|
191
196
|
{
|
|
192
197
|
loader: 'postcss-loader',
|
|
193
198
|
options: {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
postcssOptions: {
|
|
200
|
+
plugins() {
|
|
201
|
+
if (isProd) {
|
|
202
|
+
return [postcssPresetEnv(), cssnano()];
|
|
203
|
+
}
|
|
204
|
+
return [postcssPresetEnv({ browsers: 'last 2 versions' })];
|
|
205
|
+
},
|
|
200
206
|
},
|
|
201
207
|
sourceMap: !isProd,
|
|
202
208
|
},
|
|
@@ -205,7 +211,7 @@ function makeBaseConfig(options) {
|
|
|
205
211
|
loader: 'sass-loader',
|
|
206
212
|
options: {
|
|
207
213
|
sourceMap: !isProd,
|
|
208
|
-
|
|
214
|
+
additionalData: sassVariables,
|
|
209
215
|
},
|
|
210
216
|
},
|
|
211
217
|
],
|
|
@@ -235,15 +241,10 @@ function makeBaseConfig(options) {
|
|
|
235
241
|
],
|
|
236
242
|
},
|
|
237
243
|
plugins: [
|
|
238
|
-
|
|
239
|
-
new
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
ignore: ['.DS_Store'],
|
|
243
|
-
}),
|
|
244
|
-
new FixStyleOnlyEntriesPlugin({
|
|
245
|
-
silent: true,
|
|
246
|
-
}),
|
|
244
|
+
// TODO: See if we can remove
|
|
245
|
+
// new TimeFixPlugin(),
|
|
246
|
+
new CopyPlugin({ patterns: filesToCopy }),
|
|
247
|
+
new RemoveEmptyScriptsPlugin({ silent: true }),
|
|
247
248
|
],
|
|
248
249
|
resolve: {
|
|
249
250
|
symlinks: false,
|
|
@@ -256,7 +257,7 @@ function makeBaseConfig(options) {
|
|
|
256
257
|
devtool: isProd ? undefined : 'cheap-module-source-map',
|
|
257
258
|
performance: {
|
|
258
259
|
maxEntrypointSize: Infinity,
|
|
259
|
-
assetFilter: function(assetFilename) {
|
|
260
|
+
assetFilter: function (assetFilename) {
|
|
260
261
|
// Only warn about large JS assets
|
|
261
262
|
return (
|
|
262
263
|
assetFilename.includes(path.join(themeDir, 'assets')) && assetFilename.endsWith('.js')
|
|
@@ -267,10 +268,9 @@ function makeBaseConfig(options) {
|
|
|
267
268
|
minimize: isProd,
|
|
268
269
|
minimizer: [
|
|
269
270
|
new TerserPlugin({
|
|
270
|
-
cache: true,
|
|
271
271
|
parallel: true,
|
|
272
|
-
sourceMap: true,
|
|
273
272
|
terserOptions: {
|
|
273
|
+
sourceMap: true,
|
|
274
274
|
keep_classnames: true,
|
|
275
275
|
keep_fnames: true,
|
|
276
276
|
},
|
package/webpack.wp.config.js
CHANGED
|
@@ -57,13 +57,6 @@ function makeWpWebpackConfig() {
|
|
|
57
57
|
plugins: [
|
|
58
58
|
new MiniCssExtractPlugin({
|
|
59
59
|
filename: path.join(themeDir, 'assets', 'css', '[name].css'),
|
|
60
|
-
fallback: 'style-loader',
|
|
61
|
-
use: [
|
|
62
|
-
{
|
|
63
|
-
loader: 'css-loader',
|
|
64
|
-
options: { minimize: isProd, url: false, sourceMap: !isProd },
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
60
|
}),
|
|
68
61
|
],
|
|
69
62
|
};
|
package/utils/babelConfig.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const isReactProject = require('./isReactProject');
|
|
5
|
-
const logger = require('../logger');
|
|
6
|
-
|
|
7
|
-
// Check for a .babelrc file in the project directory, if not, use the default config
|
|
8
|
-
|
|
9
|
-
const getBabelConfig = () => {
|
|
10
|
-
const isReact = isReactProject();
|
|
11
|
-
|
|
12
|
-
const defaultConfig = {
|
|
13
|
-
plugins: [
|
|
14
|
-
'@babel/plugin-proposal-class-properties',
|
|
15
|
-
'@babel/plugin-proposal-object-rest-spread',
|
|
16
|
-
'@babel/plugin-proposal-export-default-from',
|
|
17
|
-
'@babel/plugin-proposal-export-namespace-from',
|
|
18
|
-
],
|
|
19
|
-
presets: [
|
|
20
|
-
[
|
|
21
|
-
'@babel/preset-env',
|
|
22
|
-
{
|
|
23
|
-
corejs: '3',
|
|
24
|
-
useBuiltIns: 'usage',
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
if (isReact) {
|
|
31
|
-
defaultConfig.presets.push('@babel/preset-react');
|
|
32
|
-
defaultConfig.plugins.push('transform-export-extensions');
|
|
33
|
-
defaultConfig.env = {
|
|
34
|
-
development: {
|
|
35
|
-
plugins: ['react-hot-loader/babel'],
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const customConfig = path.join(process.cwd(), '.babelrc');
|
|
41
|
-
|
|
42
|
-
if (fs.existsSync(customConfig)) {
|
|
43
|
-
logger.info('Using custom babel config from .babelrc');
|
|
44
|
-
return JSON.parse(fs.readFileSync(customConfig, 'utf8'));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
logger.info(`Using ${isReact ? 'react' : 'default'} babel config`);
|
|
48
|
-
|
|
49
|
-
return defaultConfig;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
module.exports = getBabelConfig();
|