Skip to content

Commit e1f512c

Browse files
committedDec 17, 2017
add mode transform and tests
1 parent 972d4cd commit e1f512c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
 

‎lib/generators/add-generator.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ module.exports = class AddGenerator extends Generator {
129129
false: {}
130130
};
131131
}
132+
if (action === "mode") {
133+
defOrPropDescription = {
134+
development: {},
135+
production: {}
136+
};
137+
}
132138
// If we've got a schema prop or devServer Schema Prop
133139
if (defOrPropDescription || webpackDevserverSchemaProp) {
134140
// Check for properties in definitions[action] or properties[action]
@@ -255,7 +261,7 @@ module.exports = class AddGenerator extends Generator {
255261
isDeepProp[1] = answerToAction.actionAnswer;
256262
if (
257263
isDeepProp[1] !== "other" &&
258-
(action === "devtool" || action === "watch")
264+
(action === "devtool" || action === "watch" || action === "mode")
259265
) {
260266
this.configuration.config.item = action;
261267
this.configuration.config.webpackOptions[action] = `'${

‎lib/init/transformations/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const moduleTransform = require("./module/module");
2828
const pluginsTransform = require("./plugins/plugins");
2929
const topScopeTransform = require("./top-scope/top-scope");
3030
const devServerTransform = require("./devServer/devServer");
31+
const modeTransform = require("./mode/mode");
3132

3233
/*
3334
* @function runTransform
@@ -60,7 +61,8 @@ const transformsObject = {
6061
pluginsTransform,
6162
topScopeTransform,
6263
mergeTransform,
63-
devServerTransform
64+
devServerTransform,
65+
modeTransform
6466
};
6567

6668
module.exports = function runTransform(webpackProperties, action) {

‎lib/utils/prop-types.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ module.exports = new Set([
1313
"target",
1414
"watch",
1515
"watchOptions",
16-
"stats"
16+
"stats",
17+
"mode"
1718
]);

0 commit comments

Comments
 (0)
Please sign in to comment.