1
1
const path = require ( 'path' ) ;
2
2
const webpack = require ( 'webpack' ) ;
3
3
const { AureliaPlugin } = require ( 'aurelia-webpack-plugin' ) ;
4
+ const bundleOutputDir = './wwwroot/dist' ;
4
5
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' } ,
11
11
resolve : {
12
- extensions : [ " .ts" , " .js" ] ,
13
- modules : [ " ClientApp" , " node_modules" ] ,
12
+ extensions : [ ' .ts' , ' .js' ] ,
13
+ modules : [ ' ClientApp' , ' node_modules' ] ,
14
14
} ,
15
- entry : { 'app' : 'aurelia-bootstrapper' } ,
16
15
output : {
17
16
path : path . resolve ( bundleOutputDir ) ,
18
- publicPath : " /dist/" ,
17
+ publicPath : ' /dist/' ,
19
18
filename : '[name].js'
20
19
} ,
21
20
module : {
22
21
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' }
28
26
]
29
27
} ,
30
28
plugins : [
@@ -33,19 +31,14 @@ module.exports = ({ prod } = {}) => {
33
31
context : __dirname ,
34
32
manifest : require ( './wwwroot/dist/vendor-manifest.json' )
35
33
} ) ,
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
+ } ] ;
48
44
}
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