wp-blank-scripts 2.6.12 → 3.0.0-beta.0
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 +8 -4
- package/lib/index.js +0 -0
- package/overridable/index.js +0 -0
- package/package.json +51 -59
- package/webpack.base.config.js +52 -51
- 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,18 @@ 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, stats) => {
|
|
92
|
+
if (err || stats.hasErrors()) {
|
|
93
|
+
logger.error(err.stack || err);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
92
97
|
const devMiddleware = webpackDevMiddleware(compiler, {
|
|
93
98
|
publicPath: config.output.publicPath,
|
|
94
99
|
stats: {
|
|
@@ -97,7 +102,6 @@ module.exports = async (envConfig = {}, buildOptions, failOnError = false) => {
|
|
|
97
102
|
warnings: true,
|
|
98
103
|
},
|
|
99
104
|
writeToDisk: true,
|
|
100
|
-
logger,
|
|
101
105
|
});
|
|
102
106
|
const hotMiddleware = webpackHotMiddleware(compiler);
|
|
103
107
|
|
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.0",
|
|
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 = [];
|
|
@@ -127,10 +127,16 @@ function makeBaseConfig(options) {
|
|
|
127
127
|
|
|
128
128
|
const mainStyleVariables = path.join(sourcePath, 'assets', 'css', 'utils', 'variables.scss');
|
|
129
129
|
|
|
130
|
-
let sassVariables
|
|
130
|
+
let sassVariables = `$env: ${process.env.NODE_ENV};`;
|
|
131
|
+
|
|
132
|
+
for (const key of Object.keys(process.env)) {
|
|
133
|
+
if (key.startsWith('VIVO_')) {
|
|
134
|
+
sassVariables += `$${key.replace('VIVO_', '').toLowerCase()}: ${process.env[key]};`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
131
137
|
|
|
132
138
|
if (fs.existsSync(mainStyleVariables)) {
|
|
133
|
-
sassVariables
|
|
139
|
+
sassVariables += fs.readFileSync(mainStyleVariables, 'utf8');
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
let loaderOverrides = {};
|
|
@@ -149,7 +155,7 @@ function makeBaseConfig(options) {
|
|
|
149
155
|
},
|
|
150
156
|
output: {
|
|
151
157
|
path: buildPath,
|
|
152
|
-
filename: chunkData => {
|
|
158
|
+
filename: (chunkData) => {
|
|
153
159
|
const name = chunkData.chunk.name === 'adminScripts' ? 'admin' : chunkData.chunk.name;
|
|
154
160
|
return path.join(themeDir, 'assets', 'js', `${name}.js`);
|
|
155
161
|
},
|
|
@@ -161,11 +167,16 @@ function makeBaseConfig(options) {
|
|
|
161
167
|
module: {
|
|
162
168
|
rules: [
|
|
163
169
|
{
|
|
164
|
-
test: /\.
|
|
170
|
+
test: /\.[jt]sx?$/,
|
|
165
171
|
exclude: /node_modules\/(?!(dom7|swiper)\/)/,
|
|
166
172
|
use: {
|
|
167
|
-
loader: '
|
|
168
|
-
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
|
+
},
|
|
169
180
|
},
|
|
170
181
|
...loaderOverrides.js,
|
|
171
182
|
},
|
|
@@ -185,12 +196,13 @@ function makeBaseConfig(options) {
|
|
|
185
196
|
{
|
|
186
197
|
loader: 'postcss-loader',
|
|
187
198
|
options: {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
postcssOptions: {
|
|
200
|
+
postcssOptions: {
|
|
201
|
+
plugins: [
|
|
202
|
+
postcssPresetEnv({ browsers: 'last 2 versions' }),
|
|
203
|
+
...(isProd ? [postcssPresetEnv(), cssnano()] : []),
|
|
204
|
+
],
|
|
205
|
+
},
|
|
194
206
|
},
|
|
195
207
|
sourceMap: !isProd,
|
|
196
208
|
},
|
|
@@ -229,28 +241,18 @@ function makeBaseConfig(options) {
|
|
|
229
241
|
],
|
|
230
242
|
},
|
|
231
243
|
plugins: [
|
|
232
|
-
|
|
233
|
-
new
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
ignore: ['.DS_Store'],
|
|
237
|
-
}),
|
|
238
|
-
new FixStyleOnlyEntriesPlugin({
|
|
239
|
-
silent: true,
|
|
240
|
-
}),
|
|
244
|
+
// TODO: See if we can remove
|
|
245
|
+
// new TimeFixPlugin(),
|
|
246
|
+
new CopyPlugin({ patterns: filesToCopy }),
|
|
247
|
+
new RemoveEmptyScriptsPlugin({ silent: true }),
|
|
241
248
|
],
|
|
242
249
|
resolve: {
|
|
243
250
|
symlinks: false,
|
|
244
|
-
alias: {
|
|
245
|
-
scrollmagic: path.resolve(
|
|
246
|
-
'node_modules/scrollmagic/scrollmagic/minified/ScrollMagic.min.js'
|
|
247
|
-
),
|
|
248
|
-
},
|
|
249
251
|
},
|
|
250
252
|
devtool: isProd ? undefined : 'cheap-module-source-map',
|
|
251
253
|
performance: {
|
|
252
254
|
maxEntrypointSize: Infinity,
|
|
253
|
-
assetFilter: function(assetFilename) {
|
|
255
|
+
assetFilter: function (assetFilename) {
|
|
254
256
|
// Only warn about large JS assets
|
|
255
257
|
return (
|
|
256
258
|
assetFilename.includes(path.join(themeDir, 'assets')) && assetFilename.endsWith('.js')
|
|
@@ -261,10 +263,9 @@ function makeBaseConfig(options) {
|
|
|
261
263
|
minimize: isProd,
|
|
262
264
|
minimizer: [
|
|
263
265
|
new TerserPlugin({
|
|
264
|
-
cache: true,
|
|
265
266
|
parallel: true,
|
|
266
|
-
sourceMap: true,
|
|
267
267
|
terserOptions: {
|
|
268
|
+
sourceMap: true,
|
|
268
269
|
keep_classnames: true,
|
|
269
270
|
keep_fnames: true,
|
|
270
271
|
},
|
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();
|