11const path = require ( 'path' ) ;
22const webpack = require ( 'webpack' ) ;
33const { AureliaPlugin } = require ( 'aurelia-webpack-plugin' ) ;
4+ const bundleOutputDir = './wwwroot/dist' ;
45
5- module . exports = ( { prod } = { } ) => {
6- const isDevBuild = ! prod ;
7- const isProdBuild = prod ;
8- const bundleOutputDir = './wwwroot/dist' ;
9-
10- return {
6+ module . exports = ( env ) => {
7+ const isDevBuild = ! ( env && env . prod ) ;
8+ return [ {
9+ stats : { modules : false } ,
10+ entry : { 'app' : 'aurelia-bootstrapper' } ,
1111 resolve : {
12- extensions : [ " .ts" , " .js" ] ,
13- modules : [ " ClientApp" , " node_modules" ] ,
12+ extensions : [ ' .ts' , ' .js' ] ,
13+ modules : [ ' ClientApp' , ' node_modules' ] ,
1414 } ,
15- entry : { 'app' : 'aurelia-bootstrapper' } ,
1615 output : {
1716 path : path . resolve ( bundleOutputDir ) ,
18- publicPath : " /dist/" ,
17+ publicPath : ' /dist/' ,
1918 filename : '[name].js'
2019 } ,
2120 module : {
2221 rules : [
23- { test : / \. c s s $ / i, use : [ isDevBuild ? 'css-loader' : 'css-loader?minimize' ] } ,
24- { test : / \. h t m l $ / i, use : [ "html-loader" ] } ,
25- { test : / \. t s $ / i, loaders : [ 'ts-loader' ] , exclude : path . resolve ( __dirname , 'node_modules' ) } ,
26- { test : / \. j s o n $ / i, loader : 'json-loader' , exclude : path . resolve ( __dirname , 'node_modules' ) } ,
27- { test : / \. ( p n g | w o f f | w o f f 2 | e o t | t t f | s v g ) $ / , loader : 'url-loader' , query : { limit : 8192 } }
22+ { test : / \. t s $ / i, include : / C l i e n t A p p / , use : 'ts-loader?silent=true' } ,
23+ { test : / \. h t m l $ / i, use : 'html-loader' } ,
24+ { test : / \. c s s $ / i, use : isDevBuild ? 'css-loader' : 'css-loader?minimize' } ,
25+ { test : / \. ( p n g | j p g | j p e g | g i f | s v g ) $ / , use : 'url-loader?limit=25000' }
2826 ]
2927 } ,
3028 plugins : [
@@ -33,19 +31,14 @@ module.exports = ({ prod } = {}) => {
3331 context : __dirname ,
3432 manifest : require ( './wwwroot/dist/vendor-manifest.json' )
3533 } ) ,
36- new AureliaPlugin ( { aureliaApp : "boot" } ) ,
37- ...when ( isDevBuild , [
38- new webpack . SourceMapDevToolPlugin ( {
39- filename : '[file].map' ,
40- moduleFilenameTemplate : path . relative ( bundleOutputDir , '[resourcePath]' )
41- } )
42- ] ) ,
43- ...when ( isProdBuild , [
44- new webpack . optimize . UglifyJsPlugin ( )
45- ] )
46- ]
47- } ;
34+ new AureliaPlugin ( { aureliaApp : 'boot' } )
35+ ] . concat ( isDevBuild ? [
36+ new webpack . SourceMapDevToolPlugin ( {
37+ filename : '[file].map' , // Remove this line if you prefer inline source maps
38+ moduleFilenameTemplate : path . relative ( bundleOutputDir , '[resourcePath]' ) // Point sourcemap entries to the original file locations on disk
39+ } )
40+ ] : [
41+ new webpack . optimize . UglifyJsPlugin ( )
42+ ] )
43+ } ] ;
4844}
49-
50- const ensureArray = ( config ) => config && ( Array . isArray ( config ) ? config : [ config ] ) || [ ]
51- const when = ( condition , config , negativeConfig ) => condition ? ensureArray ( config ) : ensureArray ( negativeConfig )
0 commit comments