@@ -123,25 +123,6 @@ class Encore {
123
123
return this ;
124
124
}
125
125
126
- /**
127
- * Allows you to configure the options passed to the extract-text-webpack-plugin.
128
- * A list of available options can be found at https://github.com/webpack-contrib/extract-text-webpack-plugin
129
- *
130
- * For example:
131
- *
132
- * Encore.configureExtractTextPlugin((options) => {
133
- * options.ignoreOrder = true;
134
- * })
135
- *
136
- * @param {function } extractTextPluginOptionsCallback
137
- * @returns {Encore }
138
- */
139
- configureExtractTextPlugin ( extractTextPluginOptionsCallback = ( ) => { } ) {
140
- webpackConfig . configureExtractTextPlugin ( extractTextPluginOptionsCallback ) ;
141
-
142
- return this ;
143
- }
144
-
145
126
/**
146
127
* Allows you to configure the options passed to the friendly-errors-webpack-plugin.
147
128
* A list of available options can be found at https://github.com/geowarin/friendly-errors-webpack-plugin
@@ -201,13 +182,17 @@ class Encore {
201
182
202
183
/**
203
184
* Allows you to configure the options passed to the uglifyjs-webpack-plugin.
204
- * A list of available options can be found at https://github.com/webpack-contrib/uglifyjs-webpack-plugin/tree/v0.4.6
185
+ * A list of available options can be found at https://github.com/webpack-contrib/uglifyjs-webpack-plugin
205
186
*
206
187
* For example:
207
188
*
208
189
* Encore.configureUglifyJsPlugin((options) => {
209
- * options.compress = false;
210
- * options.beautify = true;
190
+ * options.cache = true;
191
+ * options.uglifyOptions = {
192
+ * output: {
193
+ * comments: false
194
+ * }
195
+ * }
211
196
* })
212
197
*
213
198
* @param {function } uglifyJsPluginOptionsCallback
@@ -225,7 +210,7 @@ class Encore {
225
210
* // final output file will be main.js in the output directory
226
211
* Encore.addEntry('main', './path/to/some_file.js');
227
212
*
228
- * If the JavaScript file imports/requires CSS/SASS /LESS files,
213
+ * If the JavaScript file imports/requires CSS/Sass /LESS files,
229
214
* then a CSS file (e.g. main.css) will also be output.
230
215
*
231
216
* @param {string } name The name (without extension) that will be used
@@ -407,14 +392,98 @@ class Encore {
407
392
}
408
393
409
394
/**
410
- * Add a "commons" file that holds JS shared by multiple chunks.
395
+ * Add a "commons" file that holds JS shared by multiple chunks/files .
411
396
*
412
397
* @param {string } name The chunk name (e.g. vendor to create a vendor.js)
413
- * @param {string|Array } files Array of files to put in the vendor entry
398
+ * @param {string } file A file whose code & imports should be put into the shared file.
414
399
* @returns {Encore }
415
400
*/
416
- createSharedEntry ( name , files ) {
417
- webpackConfig . createSharedEntry ( name , files ) ;
401
+ createSharedEntry ( name , file ) {
402
+ webpackConfig . createSharedEntry ( name , file ) ;
403
+
404
+ return this ;
405
+ }
406
+
407
+ /**
408
+ * Tell Webpack to output a separate runtime.js file.
409
+ *
410
+ * This file must be included via a script tag before all
411
+ * other JavaScript files output by Encore.
412
+ *
413
+ * The runtime.js file is useful when you plan to include
414
+ * multiple entry files on the same page (e.g. a layout.js entry
415
+ * and a page-specific entry). If you are *not* including
416
+ * multiple entries on the same page, you can safely disable
417
+ * this - disableSingleRuntimeChunk() - and remove the extra script tags.
418
+ *
419
+ * If you *do* include multiple entry files on the same page,
420
+ * disabling the runtime.js file has two important consequences:
421
+ * A) Each entry file will contain the Webpack runtime, which
422
+ * means each contains some code that is duplicated in the other.
423
+ * B) If two entry files require the same module (e.g. jquery),
424
+ * they will receive *different* objects - not the *same* object.
425
+ * This can cause some confusion if you expect a "layout.js" entry
426
+ * to be able to "initialize" some jQuery plugins, because the
427
+ * jQuery required by the other entry will be a different instance,
428
+ * and so won't have the plugins initialized on it.
429
+ *
430
+ * @returns {Encore }
431
+ */
432
+ enableSingleRuntimeChunk ( ) {
433
+ webpackConfig . enableSingleRuntimeChunk ( ) ;
434
+
435
+ return this ;
436
+ }
437
+
438
+ /**
439
+ * Tell Webpack to *not* output a separate runtime.js file.
440
+ *
441
+ * See enableSingleRuntimeChunk() for more details.
442
+ *
443
+ * @returns {Encore }
444
+ */
445
+ disableSingleRuntimeChunk ( ) {
446
+ webpackConfig . disableSingleRuntimeChunk ( ) ;
447
+
448
+ return this ;
449
+ }
450
+
451
+ /**
452
+ * Tell Webpack to "split" your entry chunks.
453
+ *
454
+ * This will mean that, instead of adding 1 script tag
455
+ * to your page, your server-side code will need to read
456
+ * the entrypoints.json file in the build directory to
457
+ * determine the *multiple* .js (and .css) files that
458
+ * should be included for each entry.
459
+ *
460
+ * This is a performance optimization, but requires extra
461
+ * work (described above) to support this.
462
+ *
463
+ * @returns {Encore }
464
+ */
465
+ splitEntryChunks ( ) {
466
+ webpackConfig . splitEntryChunks ( ) ;
467
+
468
+ return this ;
469
+ }
470
+
471
+ /**
472
+ * Configure the optimization.splitChunks configuration.
473
+ *
474
+ * https://webpack.js.org/plugins/split-chunks-plugin/
475
+ *
476
+ * Encore.configureSplitChunks(function(splitChunks) {
477
+ * // change the configuration
478
+ *
479
+ * splitChunks.minSize = 0;
480
+ * });
481
+ *
482
+ * @param {function } callback
483
+ * @returns {Encore }
484
+ */
485
+ configureSplitChunks ( callback ) {
486
+ webpackConfig . configureSplitChunks ( callback ) ;
418
487
419
488
return this ;
420
489
}
@@ -654,27 +723,6 @@ class Encore {
654
723
return this ;
655
724
}
656
725
657
- /**
658
- * Call this if you plan on loading CoffeeScript files.
659
- *
660
- * Encore.enableCoffeeScriptLoader()
661
- *
662
- * Or, configure the coffee-loader options:
663
- *
664
- * Encore.enableCoffeeScriptLoader(function(coffeeScriptOptions) {
665
- * // http://coffeescript.org/#nodejs-usage
666
- * // coffeeScriptOptions.header = true;
667
- * });
668
- *
669
- * @param {function } callback
670
- * @returns {Encore }
671
- */
672
- enableCoffeeScriptLoader ( callback = ( ) => { } ) {
673
- webpackConfig . enableCoffeeScriptLoader ( callback ) ;
674
-
675
- return this ;
676
- }
677
-
678
726
/**
679
727
* Call this to enable forked type checking for TypeScript loader
680
728
* https://github.com/TypeStrong/ts-loader/blob/v2.3.0/README.md#faster-builds
@@ -981,6 +1029,22 @@ class Encore {
981
1029
runtimeConfig = null ;
982
1030
webpackConfig = null ;
983
1031
}
1032
+
1033
+ /**
1034
+ * @deprecated
1035
+ * @return {void }
1036
+ */
1037
+ configureExtractTextPlugin ( ) {
1038
+ throw new Error ( 'The configureExtractTextPlugin() method was removed from Encore. The underlying plugin was removed from Webpack 4.' ) ;
1039
+ }
1040
+
1041
+ /**
1042
+ * @deprecated
1043
+ * @return {void }
1044
+ */
1045
+ enableCoffeeScriptLoader ( ) {
1046
+ throw new Error ( 'The enableCoffeeScriptLoader() method and CoffeeScript support was removed from Encore due to support problems with Webpack 4. If you are interested in this feature, please submit a pull request!' ) ;
1047
+ }
984
1048
}
985
1049
986
1050
// Proxy the API in order to prevent calls to most of its methods
0 commit comments