Skip to content

Commit 0c03544

Browse files
committed
Adding doc
1 parent c338409 commit 0c03544

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if you need to regenerate one of the files, you can use the following CLI comman
8282
* `php protected/yii webpack/generate-config` : regenerate `webpack-yii2.json`
8383
* `php protected/yii webpack/generate-package` : regenerate `package.json`
8484
* `php protected/yii webpack/generate-webpack` : regenerate `webpack.config.js`
85+
* `php protected/yii webpack/generate-generate-typescript-config` : regenerate `tsconfig.json`
8586

8687
### Sample application structure
8788

@@ -121,13 +122,16 @@ The typical answer when running `php protected/yii webpack` would be :
121122

122123
* **Generating webpack.config.js**
123124

125+
* **Generating tsconfig.json**
126+
124127
Application structure with generated files will be
125128

126129
* *index.php*
127130
* *composer.json*
128131
* *package.json*
129132
* *webpack-yii2.json*
130133
* *webpack.config.js*
134+
* *tsconfig.json*
131135
* **protected**
132136
* *yii* (console script)
133137
* **assets**
@@ -198,13 +202,53 @@ When your assets are ready, you have to make sure following files are added to y
198202
* `package.json` node package management
199203
* `webpack.config.js` needed to run webpack
200204
* `webpack-yii2.json` needed by webpack.config.js to define you app entry points and the target directories
205+
* `tsconfig.json` needed by webpack.config.js to handle Typescript files
201206

202207
* `<appdir>/assets/webpack/assets-catalog.json` to let the webpack aware asset find the dist files
203208
* `<appdir>/assets/webpack/dist` to keep the assets (they are not dynamically generated when asset is registered)
204209
* `<appdir>/assets/webpack/src` because you want to keep your sources :-)
205210

206211

212+
### File `webpack-yii2.json` explained
213+
214+
```json
215+
{
216+
"sourceDir": "protected\/assets\/webpack",
217+
"entry": {
218+
"app": "./app.ts"
219+
},
220+
"commonBundles": [
221+
"manifest"
222+
],
223+
"externals": {
224+
225+
},
226+
"subDirectories": {
227+
"sources": "src",
228+
"dist": "dist"
229+
},
230+
"assets": {
231+
"styles": "css",
232+
"scripts": "js"
233+
},
234+
"catalog": "assets-catalog.json"
235+
}
236+
```
207237

238+
#### Specific to yii2-webpack module
239+
240+
* **sourceDir** relative path to the directory where assets will be managed
241+
* **subDirectories** subpath (in *< sourceDir >*) of sources and distribution files
242+
* **assets** subpath (in *< sourceDir >/< subDirectories.dist >*) of styles and scripts assets
243+
* **catalog** name of assets catalog, must be in synch with `WebpackAssetBundle::$webpackAssetCatalog`
244+
245+
#### Mapped to Webpack vars
246+
247+
* **entry** object syntax entry points [Webpack entry documentation](https://webpack.js.org/concepts/entry-points/#object-syntax)
248+
* **commonBundles** explicit vendor chunk [Webpack CommonChunkPlugin documentation](https://webpack.js.org/plugins/commons-chunk-plugin/#explicit-vendor-chunk)
249+
* **externals** object syntax externals [Webpack externals documentation](https://webpack.js.org/configuration/externals/#object)
250+
251+
208252
Contributing
209253
------------
210254

0 commit comments

Comments
 (0)