@caweb/cli 1.15.3 → 1.15.4
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/commands/webpack/webpack.js +66 -0
- package/package.json +1 -1
|
@@ -11,6 +11,42 @@ import {
|
|
|
11
11
|
runCmd
|
|
12
12
|
} from '../../lib/index.js';
|
|
13
13
|
|
|
14
|
+
const webpackAllowedFlags = [
|
|
15
|
+
"-c",
|
|
16
|
+
"--config",
|
|
17
|
+
"--config-name",
|
|
18
|
+
"-m",
|
|
19
|
+
"--merge",
|
|
20
|
+
"--disable-interpret",
|
|
21
|
+
"--env",
|
|
22
|
+
"--node-env",
|
|
23
|
+
"--config-node-env",
|
|
24
|
+
"--analyze",
|
|
25
|
+
"--progress",
|
|
26
|
+
"-j",
|
|
27
|
+
"--json",
|
|
28
|
+
"--fail-on-warnings",
|
|
29
|
+
"-d",
|
|
30
|
+
"--devtool",
|
|
31
|
+
"--no-devtool",
|
|
32
|
+
"--entry",
|
|
33
|
+
"-e",
|
|
34
|
+
"--extends",
|
|
35
|
+
"--mode",
|
|
36
|
+
"--name",
|
|
37
|
+
"-o",
|
|
38
|
+
"--output-path",
|
|
39
|
+
"--stats",
|
|
40
|
+
"--no-stats",
|
|
41
|
+
"-t",
|
|
42
|
+
"--target",
|
|
43
|
+
"--no-target",
|
|
44
|
+
"-w",
|
|
45
|
+
"--watch",
|
|
46
|
+
"--no-watch",
|
|
47
|
+
"--watch-options-stdin",
|
|
48
|
+
"--no-watch-options-stdin",
|
|
49
|
+
];
|
|
14
50
|
|
|
15
51
|
/**
|
|
16
52
|
* Build the current project
|
|
@@ -65,6 +101,35 @@ export default async function webpack({
|
|
|
65
101
|
// add the --merge flag to allow merging configs.
|
|
66
102
|
webPackArgs.push( '--merge' );
|
|
67
103
|
|
|
104
|
+
let unknown = false;
|
|
105
|
+
let unkownArgs = [];
|
|
106
|
+
|
|
107
|
+
// we have to filter out unknown args to avoid webpack errors
|
|
108
|
+
webPackArgs = webPackArgs.filter( (e) => {
|
|
109
|
+
|
|
110
|
+
if( e.startsWith('--') ){
|
|
111
|
+
// set unknown flag
|
|
112
|
+
unknown = ! webpackAllowedFlags.includes(e);
|
|
113
|
+
|
|
114
|
+
// save unknown flag
|
|
115
|
+
if( unknown ){
|
|
116
|
+
unkownArgs.push(e);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// return if known flag
|
|
120
|
+
return webpackAllowedFlags.includes(e);
|
|
121
|
+
}else{
|
|
122
|
+
// save unknown args
|
|
123
|
+
if( unknown ){
|
|
124
|
+
unkownArgs.push(e);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// if flag was known return the value, else false
|
|
128
|
+
return ! unknown ? e : false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
|
|
68
133
|
// run the webpackCommand command.
|
|
69
134
|
await runCmd(
|
|
70
135
|
'webpack',
|
|
@@ -74,6 +139,7 @@ export default async function webpack({
|
|
|
74
139
|
],
|
|
75
140
|
{
|
|
76
141
|
stdio: 'inherit',
|
|
142
|
+
argv0: unkownArgs.join(' ')
|
|
77
143
|
}
|
|
78
144
|
);
|
|
79
145
|
};
|