@@ -60,13 +60,15 @@ module.exports = {
6060 ] ,
6161 } ,
6262 target : 'web' ,
63+
6364 node : {
6465 process : false ,
6566 Buffer : false ,
6667 setImmediate : false ,
6768 module : 'empty' ,
6869 child_process : 'empty' ,
6970 } ,
71+
7072 output : {
7173 path : paths . appBuild ,
7274 pathinfo : true ,
@@ -249,61 +251,84 @@ module.exports = {
249251 } ,
250252 ] ,
251253 } ) ,
252- // Generates an `index.html` file with the <script> injected.
253- new HtmlWebpackPlugin ( {
254- inject : true ,
255- chunks : [ 'common-sandbox' , 'common' , 'app' ] ,
256- filename : 'app.html' ,
257- template : paths . appHtml ,
258- minify : __PROD__ && {
259- removeComments : false ,
260- collapseWhitespace : true ,
261- removeRedundantAttributes : true ,
262- useShortDoctype : true ,
263- removeEmptyAttributes : true ,
264- removeStyleLinkTypeAttributes : true ,
265- keepClosingSlash : true ,
266- minifyJS : true ,
267- minifyCSS : true ,
268- minifyURLs : true ,
269- } ,
270- } ) ,
271- new HtmlWebpackPlugin ( {
272- inject : true ,
273- chunks : [ 'sandbox-startup' , 'common-sandbox' , 'sandbox' ] ,
274- filename : 'frame.html' ,
275- template : paths . sandboxHtml ,
276- minify : __PROD__ && {
277- removeComments : true ,
278- collapseWhitespace : true ,
279- removeRedundantAttributes : true ,
280- useShortDoctype : true ,
281- removeEmptyAttributes : true ,
282- removeStyleLinkTypeAttributes : true ,
283- keepClosingSlash : true ,
284- minifyJS : true ,
285- minifyCSS : true ,
286- minifyURLs : true ,
287- } ,
288- } ) ,
289- new HtmlWebpackPlugin ( {
290- inject : true ,
291- chunks : [ 'common-sandbox' , 'common' , 'embed' ] ,
292- filename : 'embed.html' ,
293- template : path . join ( paths . embedSrc , 'index.html' ) ,
294- minify : __PROD__ && {
295- removeComments : true ,
296- collapseWhitespace : true ,
297- removeRedundantAttributes : true ,
298- useShortDoctype : true ,
299- removeEmptyAttributes : true ,
300- removeStyleLinkTypeAttributes : true ,
301- keepClosingSlash : true ,
302- minifyJS : true ,
303- minifyCSS : true ,
304- minifyURLs : true ,
305- } ,
306- } ) ,
254+ ...( SANDBOX_ONLY
255+ ? [
256+ new HtmlWebpackPlugin ( {
257+ inject : true ,
258+ chunks : [ 'sandbox-startup' , 'sandbox' ] ,
259+ filename : 'frame.html' ,
260+ template : paths . sandboxHtml ,
261+ minify : __PROD__ && {
262+ removeComments : true ,
263+ collapseWhitespace : true ,
264+ removeRedundantAttributes : true ,
265+ useShortDoctype : true ,
266+ removeEmptyAttributes : true ,
267+ removeStyleLinkTypeAttributes : true ,
268+ keepClosingSlash : true ,
269+ minifyJS : true ,
270+ minifyCSS : true ,
271+ minifyURLs : true ,
272+ } ,
273+ } ) ,
274+ ]
275+ : [
276+ // Generates an `index.html` file with the <script> injected.
277+ new HtmlWebpackPlugin ( {
278+ inject : true ,
279+ chunks : [ 'common-sandbox' , 'common' , 'app' ] ,
280+ filename : 'app.html' ,
281+ template : paths . appHtml ,
282+ minify : __PROD__ && {
283+ removeComments : false ,
284+ collapseWhitespace : true ,
285+ removeRedundantAttributes : true ,
286+ useShortDoctype : true ,
287+ removeEmptyAttributes : true ,
288+ removeStyleLinkTypeAttributes : true ,
289+ keepClosingSlash : true ,
290+ minifyJS : true ,
291+ minifyCSS : true ,
292+ minifyURLs : true ,
293+ } ,
294+ } ) ,
295+ new HtmlWebpackPlugin ( {
296+ inject : true ,
297+ chunks : [ 'sandbox-startup' , 'common-sandbox' , 'sandbox' ] ,
298+ filename : 'frame.html' ,
299+ template : paths . sandboxHtml ,
300+ minify : __PROD__ && {
301+ removeComments : true ,
302+ collapseWhitespace : true ,
303+ removeRedundantAttributes : true ,
304+ useShortDoctype : true ,
305+ removeEmptyAttributes : true ,
306+ removeStyleLinkTypeAttributes : true ,
307+ keepClosingSlash : true ,
308+ minifyJS : true ,
309+ minifyCSS : true ,
310+ minifyURLs : true ,
311+ } ,
312+ } ) ,
313+ new HtmlWebpackPlugin ( {
314+ inject : true ,
315+ chunks : [ 'common-sandbox' , 'common' , 'embed' ] ,
316+ filename : 'embed.html' ,
317+ template : path . join ( paths . embedSrc , 'index.html' ) ,
318+ minify : __PROD__ && {
319+ removeComments : true ,
320+ collapseWhitespace : true ,
321+ removeRedundantAttributes : true ,
322+ useShortDoctype : true ,
323+ removeEmptyAttributes : true ,
324+ removeStyleLinkTypeAttributes : true ,
325+ keepClosingSlash : true ,
326+ minifyJS : true ,
327+ minifyCSS : true ,
328+ minifyURLs : true ,
329+ } ,
330+ } ) ,
331+ ] ) ,
307332 // Makes some environment variables available to the JS code, for example:
308333 // if (process.env.NODE_ENV === 'development') { ... }. See `env.js`.
309334 new webpack . DefinePlugin ( env ) ,
@@ -323,10 +348,11 @@ module.exports = {
323348
324349 // With this plugin we override the load-rules of eslint, this function prevents
325350 // us from using eslint in the browser, therefore we need to stop it!
326- new webpack . NormalModuleReplacementPlugin (
327- new RegExp ( [ 'eslint' , 'lib' , 'load-rules' ] . join ( `\\${ path . sep } ` ) ) ,
328- path . join ( paths . config , 'stubs/load-rules.compiled.js' )
329- ) ,
351+ ! SANDBOX_ONLY &&
352+ new webpack . NormalModuleReplacementPlugin (
353+ new RegExp ( [ 'eslint' , 'lib' , 'load-rules' ] . join ( `\\${ path . sep } ` ) ) ,
354+ path . join ( paths . config , 'stubs/load-rules.compiled.js' )
355+ ) ,
330356
331357 // If you require a missing module and then `npm install` it, you still have
332358 // to restart the development server for Webpack to discover it. This plugin
@@ -356,23 +382,28 @@ module.exports = {
356382 } ,
357383 ] . filter ( x => x )
358384 ) ,
359- // We first create a common chunk between embed and app, to share components
360- // and dependencies.
361- new webpack . optimize . CommonsChunkPlugin ( {
362- name : 'common' ,
363- chunks : [ 'app' , 'embed' ] ,
364- } ) ,
365- // Then we find all commonalities between sandbox and common, because sandbox
366- // is always loaded by embed and app.
367- new webpack . optimize . CommonsChunkPlugin ( {
368- name : 'common-sandbox' ,
369- chunks : [ 'common' , 'sandbox' ] ,
370- } ) ,
371- new webpack . optimize . CommonsChunkPlugin ( {
372- async : true ,
373- children : true ,
374- minChunks : 2 ,
375- } ) ,
385+
386+ ...( SANDBOX_ONLY
387+ ? [ ]
388+ : [
389+ // We first create a common chunk between embed and app, to share components
390+ // and dependencies.
391+ new webpack . optimize . CommonsChunkPlugin ( {
392+ name : 'common' ,
393+ chunks : [ 'app' , 'embed' ] ,
394+ } ) ,
395+ // Then we find all commonalities between sandbox and common, because sandbox
396+ // is always loaded by embed and app.
397+ new webpack . optimize . CommonsChunkPlugin ( {
398+ name : 'common-sandbox' ,
399+ chunks : [ 'common' , 'sandbox' ] ,
400+ } ) ,
401+ new webpack . optimize . CommonsChunkPlugin ( {
402+ async : true ,
403+ children : true ,
404+ minChunks : 2 ,
405+ } ) ,
406+ ] ) ,
376407 new webpack . NamedModulesPlugin ( ) ,
377- ] ,
408+ ] . filter ( Boolean ) ,
378409} ;
0 commit comments