Skip to content

Commit

Permalink
add mode transform and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed Dec 17, 2017
1 parent 972d4cd commit e1f512c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/generators/add-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ module.exports = class AddGenerator extends Generator {
false: {}
};
}
if (action === "mode") {
defOrPropDescription = {
development: {},
production: {}
};
}
// If we've got a schema prop or devServer Schema Prop
if (defOrPropDescription || webpackDevserverSchemaProp) {
// Check for properties in definitions[action] or properties[action]
Expand Down Expand Up @@ -255,7 +261,7 @@ module.exports = class AddGenerator extends Generator {
isDeepProp[1] = answerToAction.actionAnswer;
if (
isDeepProp[1] !== "other" &&
(action === "devtool" || action === "watch")
(action === "devtool" || action === "watch" || action === "mode")
) {
this.configuration.config.item = action;
this.configuration.config.webpackOptions[action] = `'${
Expand Down
4 changes: 3 additions & 1 deletion lib/init/transformations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const moduleTransform = require("./module/module");
const pluginsTransform = require("./plugins/plugins");
const topScopeTransform = require("./top-scope/top-scope");
const devServerTransform = require("./devServer/devServer");
const modeTransform = require("./mode/mode");

/*
* @function runTransform
Expand Down Expand Up @@ -60,7 +61,8 @@ const transformsObject = {
pluginsTransform,
topScopeTransform,
mergeTransform,
devServerTransform
devServerTransform,
modeTransform
};

module.exports = function runTransform(webpackProperties, action) {
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module.exports = new Set([
"target",
"watch",
"watchOptions",
"stats"
"stats",
"mode"
]);

0 comments on commit e1f512c

Please sign in to comment.