@caweb/webpack 2.0.1 → 2.0.3
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/lib/args.js +7 -54
- package/lib/handlebars.js +3 -1
- package/lib/loader.js +3 -1
- package/package.json +2 -2
- package/tests/webpack.tests.js +2 -4
- package/webpack.config.js +0 -8
package/lib/args.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { parseArgs } from 'node:util';
|
|
4
|
+
// import { parseArgs } from 'node:util';
|
|
5
|
+
import minimist from 'minimist';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -16,62 +17,14 @@ let argv0 = process.argv0.replace(/.*node[.a-z\s]*/, '');
|
|
|
16
17
|
// flags can be passed via argv0
|
|
17
18
|
// we also add args from NODE_OPTIONS
|
|
18
19
|
// we also add args from CAWEB_NODE_OPTIONS
|
|
19
|
-
let
|
|
20
|
-
args: [
|
|
20
|
+
let flags = minimist( [
|
|
21
21
|
...argv,
|
|
22
22
|
...argv0.split(' '),
|
|
23
23
|
...(process.env.NODE_OPTIONS ? process.env.NODE_OPTIONS.trim().replace(/(^'|'$)/g, '').split(' ') : []).filter( Boolean ),
|
|
24
24
|
...(process.env.CAWEB_NODE_OPTIONS ? process.env.CAWEB_NODE_OPTIONS.trim().replace(/(^'|'$)/g, '').split(' ') : []).filter( Boolean )
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
allowNegative: true,
|
|
29
|
-
|
|
30
|
-
// in order for the flags to work with the cli's params,
|
|
31
|
-
// we need to set the options
|
|
32
|
-
options: {
|
|
33
|
-
template: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
},
|
|
36
|
-
scheme: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
},
|
|
39
|
-
cwd: {
|
|
40
|
-
type: 'string',
|
|
41
|
-
},
|
|
42
|
-
update: {
|
|
43
|
-
type: 'boolean',
|
|
44
|
-
},
|
|
45
|
-
xdebug: {
|
|
46
|
-
type: 'string'
|
|
47
|
-
},
|
|
48
|
-
spx: {
|
|
49
|
-
type: 'string'
|
|
50
|
-
},
|
|
51
|
-
scripts: {
|
|
52
|
-
type: 'boolean',
|
|
53
|
-
},
|
|
54
|
-
sync: {
|
|
55
|
-
type: 'boolean',
|
|
56
|
-
},
|
|
57
|
-
plugin: {
|
|
58
|
-
type: 'boolean',
|
|
59
|
-
short: 'p'
|
|
60
|
-
},
|
|
61
|
-
theme: {
|
|
62
|
-
type: 'boolean',
|
|
63
|
-
short: 't'
|
|
64
|
-
},
|
|
65
|
-
multisite: {
|
|
66
|
-
type: 'boolean',
|
|
67
|
-
short: 'm'
|
|
68
|
-
},
|
|
69
|
-
subdomain: {
|
|
70
|
-
type: 'boolean',
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} )
|
|
74
|
-
|
|
25
|
+
].filter( Boolean )
|
|
26
|
+
)
|
|
27
|
+
|
|
75
28
|
// function to add a flag
|
|
76
29
|
function addFlag(flag, value = null){
|
|
77
30
|
if( ! flagExists(flag) ){
|
|
@@ -81,7 +34,7 @@ function addFlag(flag, value = null){
|
|
|
81
34
|
|
|
82
35
|
// check if a flag exists
|
|
83
36
|
function flagExists(flag){
|
|
84
|
-
//
|
|
37
|
+
// minimist removes the leading dashes from flags, so we need to account for that
|
|
85
38
|
return Object.keys(flags).includes(flag.replace(/^-+/, ''));
|
|
86
39
|
}
|
|
87
40
|
|
package/lib/handlebars.js
CHANGED
|
@@ -17,7 +17,9 @@ let templatePartials = {
|
|
|
17
17
|
'header': 'semantics/header.html',
|
|
18
18
|
'mobileControls': 'semantics/mobile-controls.html',
|
|
19
19
|
'navFooter': 'semantics/nav-footer.html',
|
|
20
|
-
'
|
|
20
|
+
'navSingle': 'semantics/nav-single.html',
|
|
21
|
+
'navDropdown': 'semantics/nav-dropdown.html',
|
|
22
|
+
'navMegaDropdown': 'semantics/nav-mega-dropdown.html',
|
|
21
23
|
'utilityHeader': 'semantics/utility-header.html',
|
|
22
24
|
'head': 'semantics/head.html',
|
|
23
25
|
'alert': 'components/alert/alert.html',
|
package/lib/loader.js
CHANGED
|
@@ -41,7 +41,9 @@ const partialResolver = ( partial, callback ) => {
|
|
|
41
41
|
case 'header':
|
|
42
42
|
case 'mobileControls':
|
|
43
43
|
case 'navFooter':
|
|
44
|
-
case '
|
|
44
|
+
case 'navSingle':
|
|
45
|
+
case 'navDropdown':
|
|
46
|
+
case 'navMegaDropdown':
|
|
45
47
|
case 'utilityHeader':
|
|
46
48
|
case 'head':
|
|
47
49
|
partialDir = 'semantics';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/webpack",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "CAWebPublishing Webpack Configuration",
|
|
5
5
|
"main": "webpack.config.js",
|
|
6
6
|
"files": [
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"source-map-loader": "^5.0.0",
|
|
62
62
|
"thread-loader": "^4.0.4",
|
|
63
63
|
"ts-loader": "^9.5.4",
|
|
64
|
-
"webpack": "^5.105.
|
|
64
|
+
"webpack": "^5.105.3",
|
|
65
65
|
"webpack-cli": "^6.0.1",
|
|
66
66
|
"webpack-dev-server": "^5.2.3",
|
|
67
67
|
"webpack-merge": "^6.0.1",
|
package/tests/webpack.tests.js
CHANGED
|
@@ -9,8 +9,6 @@ import path from 'path';
|
|
|
9
9
|
import fs from 'fs';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
11
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
12
|
-
import deepmerge from 'deepmerge';
|
|
13
|
-
import Handlebars from 'handlebars';
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* Internal Dependencies
|
|
@@ -29,10 +27,10 @@ let testCaweb = JSON.parse( fs.readFileSync( path.join(currentPath, 'caweb.json'
|
|
|
29
27
|
// we read the app caweb.json file if it exists
|
|
30
28
|
let defaultCaweb = fs.existsSync( path.join(appPath, 'caweb.json') ) ?
|
|
31
29
|
JSON.parse(fs.readFileSync(path.join(appPath, 'caweb.json')))
|
|
32
|
-
:
|
|
30
|
+
: null;
|
|
33
31
|
|
|
34
32
|
// merge the two caweb.json files, with the project data taking precedence
|
|
35
|
-
let caweb =
|
|
33
|
+
let caweb = defaultCaweb ?? testCaweb;
|
|
36
34
|
|
|
37
35
|
let templatePath = path.join(appPath, 'node_modules', '@caweb', 'template');
|
|
38
36
|
let template = getArgVal( 'template', path.join(templatePath, 'patterns', 'default.html') );
|
package/webpack.config.js
CHANGED
|
@@ -154,14 +154,6 @@ let webpackConfig = {
|
|
|
154
154
|
]
|
|
155
155
|
},
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* Devtool Configuration
|
|
159
|
-
* WordPress by default uses 'source-map' for devtool which affects build and rebuild speed.
|
|
160
|
-
* For development we switch to 'eval' which is much faster.
|
|
161
|
-
* @see https://webpack.js.org/configuration/devtool/#devtool
|
|
162
|
-
*/
|
|
163
|
-
devtool: isProduction ? 'source-map' : 'eval',
|
|
164
|
-
|
|
165
157
|
/**
|
|
166
158
|
* Turn off caching of generated modules and chunks.
|
|
167
159
|
* @see https://webpack.js.org/configuration/cache/
|