You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To create a `scaffold`, you must create a [`yeoman-generator`](http://yeoman.io/authoring/). Because of that, you can optionally extend your generator to include methods from the [Yeoman API](http://yeoman.io/learning/). Its worth noting that we support all the properties of a regular webpack configuration. In order for us to do this, there's a thing you need to remember.
63
+
To create a `scaffold`, you must create a [`yeoman-generator`](http://yeoman.io/authoring/). Because of that, you can optionally extend your generator to include methods from the [Yeoman API](http://yeoman.io/learning/). It's worth noting that we support all the properties of a regular webpack configuration. In order for us to do this, there's a thing you need to remember:
64
64
65
-
Objects are made using strings, while strings are made using double strings. This means that in order for you to create a string, you have to wrap it inside another string for us to validate it correctly.
65
+
> Objects are made using strings, while strings are made using double strings. This means that in order for you to create a string, you have to wrap it inside another string for us to validate it correctly.
Is initialized inside the constructor of your generator in order for the CLI to work.
80
+
This is the entry point your configuration, initialize it inside the constructor of your generator in order for the CLI to work:
81
81
82
82
```js
83
83
constructor(args, opts) {
84
84
super(args, opts);
85
85
opts.env.configuration= {};
86
86
}
87
87
```
88
+
### `opts.env.configuration.myObj` (required)
88
89
89
-
### `opts.env.configuration.myConfig` (required)
90
-
91
-
Every `myConfig` will be transformed into a webpack configuration. You can name those keys as you prefer (e.g. `dev`, `prod`):
90
+
This is your scaffold, you add here the options that the CLI will transform into a Webpack configuration. You can have many different scaffolds named as you prefer, representing different configurations like `dev.config` or `prod.config`:
92
91
93
92
```js
94
93
constructor(args, opts) {
@@ -100,56 +99,50 @@ constructor(args, opts) {
100
99
}
101
100
```
102
101
103
-
### `myConfig.webpackOptions` (required)
104
-
105
-
This object behaves as a regular webpack configuration, you declare here properties you want to scaffold, like `entry`, `output` and `context`:
102
+
### `myObj.webpackOptions` (required)
106
103
107
-
(Inside a yeoman method)
104
+
This object has the same format as a regular Webpack configuration, so you declare here the properties that you want to scaffold, like `entry`, `output` and `context`. You can intialize this inside a yeoman method:
For the scaffolding instance to run, you need to write your configuration to a `.yo-rc.json` file. This could be done using one of the lifecycles in the yeoman generator, such as the `writing` method:
115
+
If you want to use [`webpack-merge`](https://github.com/survivejs/webpack-merge), you can set the `merge` property of `myObj` to the name of the configuration you want to merge it with:
If you want to use `webpack-merge`, you can set the `merge` property with the name of the configuration you want to merge with:
123
+
The `topScope` property is where you write all the special code needed by your configuration, like module imports and function/variables definitions:
131
124
132
125
```js
133
-
this.options.env.configuration.dev= {
134
-
merge:'anotherConfig'
135
-
};
126
+
this.options.env.configuration.dev.topScope= [
127
+
'const webpack = require(\'webpack\');',
128
+
'const path = require(\'path\');'
129
+
];
136
130
```
137
131
138
-
### `myConfig.topScope`(optional)
132
+
### `myObj.configName`(optional)
139
133
140
-
The `topScope` property is a way for the to add special behaviours to your scaffold, like functions that could be called inside a configuration, variable initializations and module imports:
134
+
`configName` allows you to customize the name of your configuration file. For example you can name it `webpack.base.js` instead of the default `webpack.config.js`:
Used if you want to name your `webpack.config.js` differently:
142
+
For the scaffolding instance to run, you need to write your configuration to a `.yo-rc.json` file. This could be done using one of the lifecycles in the yeoman generator, such as the `writing` method:
0 commit comments