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
@@ -537,7 +537,7 @@ Note this option is called filename but you are still allowed to use something l
537
537
538
538
Note this option does not affect output files for on-demand-loaded chunks. It only affects output files that are initially loaded. For on-demand-loaded chunk files the [`output.chunkFilename`](#outputchunkfilename) option is used. Files created by loaders also aren't affected. In this case you would have to try the specific loader's available options.
539
539
540
-
## Template strings
540
+
###Template strings
541
541
542
542
The following substitutions are available in template strings (via webpack's internal [`TemplatedPathPlugin`](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js)):
543
543
@@ -629,45 +629,41 @@ type ModulePathData = {
629
629
630
630
T> In some context properties will use JavaScript code expressions instead of raw values. In these cases the `WithLength` variant is available and should be used instead of slicing the original value.
631
631
632
-
## `output.globalObject`
633
-
634
-
`string = 'window'`
632
+
## output.futureEmitAssets
635
633
636
-
When targeting a library, especially when `libraryTarget` is `'umd'`, this option indicates what global object will be used to mount the library. To make UMD build available on both browsers and Node.js, set `output.globalObject` option to `'this'`. Defaults to `self` for Web-like targets.
634
+
`boolean = false`
637
635
638
-
For example:
636
+
Tells webpack to use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after they were emitted.
639
637
640
-
**webpack.config.js**
638
+
W> `output.futureEmitAssets` option will be removed in webpack v5.0.0 and this behaviour will become the new default.
641
639
642
640
```javascript
643
641
module.exports= {
644
-
//...
642
+
//...
645
643
output: {
646
-
library:'myLib',
647
-
libraryTarget:'umd',
648
-
filename:'myLib.js',
649
-
globalObject:'this',
644
+
futureEmitAssets:true,
650
645
},
651
646
};
652
647
```
653
648
654
-
## `output.uniqueName`
655
-
656
-
`string`
649
+
## `output.globalObject`
657
650
658
-
A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to [`output.library`](/configuration/output/#outputlibrary) name or the package name from `package.json` in the context, if both aren't found, it is set to an `''`.
651
+
`string = 'window'`
659
652
660
-
`output.uniqueName`will be used to generate unique globals for:
653
+
When targeting a library, especially when `libraryTarget` is `'umd'`, this option indicates what global object will be used to mount the library. To make UMD build available on both browsers and Node.js, set `output.globalObject` option to `'this'`. Defaults to `self`for Web-like targets.
@@ -744,6 +740,38 @@ Customize the main hot update filename. `[fullhash]` and `[runtime]` are availab
744
740
745
741
T> Typically you don't need to change `output.hotUpdateMainFilename`.
746
742
743
+
## output.iife
744
+
745
+
`boolean = true`
746
+
747
+
Tells webpack to add [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) wrapper around emitted code.
748
+
749
+
```javascript
750
+
module.exports= {
751
+
//...
752
+
output: {
753
+
iife:true,
754
+
},
755
+
};
756
+
```
757
+
758
+
## output.importFunctionName
759
+
760
+
`string = 'import'`
761
+
762
+
The name of the native `import()` function. Can be used for polyfilling, e.g. with [`dynamic-import-polyfill`](https://github.com/GoogleChromeLabs/dynamic-import-polyfill).
763
+
764
+
**webpack.config.js**
765
+
766
+
```javascript
767
+
module.exports= {
768
+
//...
769
+
output: {
770
+
importFunctionName:'__import__',
771
+
},
772
+
};
773
+
```
774
+
747
775
## output.library
748
776
749
777
Output a library exposing the exports of your entry point.
The dependencies for your library will be defined by the [`externals`](/configuration/externals/) config.
1851
1879
1852
-
## `output.importFunctionName`
1880
+
## output.module
1853
1881
1854
-
`string = 'import'`
1882
+
`boolean = false`
1855
1883
1856
-
The name of the native `import()` function. Can be used for polyfilling, e.g. with [`dynamic-import-polyfill`](https://github.com/GoogleChromeLabs/dynamic-import-polyfill).
1884
+
Output JavaScript files as module type. Disabled by default as it's an experimental feature.
1857
1885
1858
-
**webpack.config.js**
1886
+
When enabled, webpack will set [`output.iife`](#outputiife) to `false`, [`output.scriptType`](#outputscripttype) to `'module'` and `terserOptions.module` to `true` internally.
1887
+
1888
+
If you're using webpack to compile a library to be consumed by others, make sure to set [`output.libraryTarget`](#librarytarget-module) to `'module'` when `output.module` is `true`.
1859
1889
1860
1890
```javascript
1861
1891
module.exports= {
1862
1892
//...
1893
+
experiments: {
1894
+
outputModule:true,
1895
+
},
1863
1896
output: {
1864
-
importFunctionName:'__import__',
1897
+
module:true,
1865
1898
},
1866
1899
};
1867
1900
```
1868
1901
1902
+
W> `output.module` is an experimental feature and can only be enabled by setting [`experiments.outputModule`](/configuration/experiments/#experiments) to `true`.
The new option `workerChunkLoading` controls the chunk loading of workers.
2149
-
2150
-
T> The default value of this option is depending on the `target` setting. For more details, search for `"workerChunkLoading"`: [in the webpack defaults](https://github.com/webpack/webpack/blob/master/lib/config/defaults.js).
2151
-
2152
-
**webpack.config.js**
2179
+
## output.uniqueName
2153
2180
2154
-
```javascript
2155
-
module.exports= {
2156
-
//...
2157
-
output: {
2158
-
workerChunkLoading:false,
2159
-
},
2160
-
};
2161
-
```
2181
+
`string`
2162
2182
2163
-
## `output.futureEmitAssets`
2183
+
A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to [`output.library`](/configuration/output/#outputlibrary) name or the package name from `package.json` in the context, if both aren't found, it is set to an `''`.
2164
2184
2165
-
`boolean = false`
2185
+
`output.uniqueName` will be used to generate unique globals for:
2166
2186
2167
-
Tells webpack to use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after they were emitted.
Output JavaScript files as module type. Disabled by default as it's an experimental feature.
2224
+
The new option `workerChunkLoading` controls the chunk loading of workers.
2220
2225
2221
-
When enabled, webpack will set [`output.iife`](#outputiife) to `false`, [`output.scriptType`](#outputscripttype) to `'module'` and `terserOptions.module` to `true` internally.
2226
+
T> The default value of this option is depending on the `target` setting. For more details, search for `"workerChunkLoading"`: [in the webpack defaults](https://github.com/webpack/webpack/blob/master/lib/config/defaults.js).
2222
2227
2223
-
If you're using webpack to compile a library to be consumed by others, make sure to set [`output.libraryTarget`](#librarytarget-module) to `'module'` when `output.module` is `true`.
2228
+
**webpack.config.js**
2224
2229
2225
2230
```javascript
2226
2231
module.exports= {
2227
2232
//...
2228
-
experiments: {
2229
-
outputModule:true,
2230
-
},
2231
2233
output: {
2232
-
module:true,
2234
+
workerChunkLoading:false,
2233
2235
},
2234
2236
};
2235
2237
```
2236
-
2237
-
W> `output.module` is an experimental feature and can only be enabled by setting [`experiments.outputModule`](/configuration/experiments/#experiments) to `true`.
0 commit comments