|
1 | | -varisDevBuild=process.argv.indexOf('--env.prod')<0; |
2 | | -varpath=require('path'); |
3 | | -varwebpack=require('webpack'); |
4 | | -varExtractTextPlugin=require('extract-text-webpack-plugin'); |
| 1 | +constpath=require('path'); |
| 2 | +constwebpack=require('webpack'); |
| 3 | +constExtractTextPlugin=require('extract-text-webpack-plugin'); |
| 4 | +constCheckerPlugin=require('awesome-typescript-loader').CheckerPlugin; |
| 5 | +constbundleOutputDir='./wwwroot/dist'; |
5 | 6 |
|
6 | | -varbundleOutputDir='./wwwroot/dist'; |
7 | | -module.exports={ |
8 | | -entry: {'main': './ClientApp/boot.ts'}, |
9 | | -resolve: {extensions: ['','.js','.ts']}, |
10 | | -output: { |
11 | | -path: path.join(__dirname,bundleOutputDir), |
12 | | -filename: '[name].js', |
13 | | -publicPath: '/dist/' |
14 | | -}, |
15 | | -module: { |
16 | | -loaders: [ |
17 | | -{test: /\.ts$/,include: /ClientApp/,loader: 'ts-loader',query: {silent: true}}, |
18 | | -{test: /\.html$/,loader: 'raw-loader'}, |
19 | | -{test: /\.css$/,loader: isDevBuild ? 'style-loader!css-loader' : ExtractTextPlugin.extract(['css-loader'])}, |
20 | | -{test: /\.(png|jpg|jpeg|gif|svg)$/,loader: 'url-loader',query: {limit: 25000}}, |
21 | | -{test: /\.json$/,loader: 'json-loader'} |
22 | | -] |
23 | | -}, |
24 | | -plugins: [ |
25 | | -newwebpack.DllReferencePlugin({ |
26 | | -context: __dirname, |
27 | | -manifest: require('./wwwroot/dist/vendor-manifest.json') |
28 | | -}) |
29 | | -].concat(isDevBuild ? [ |
30 | | -// Plugins that apply in development builds only |
31 | | -newwebpack.SourceMapDevToolPlugin({ |
32 | | -filename: '[file].map',// Remove this line if you prefer inline source maps |
33 | | -moduleFilenameTemplate: path.relative(bundleOutputDir,'[resourcePath]')// Point sourcemap entries to the original file locations on disk |
34 | | -}) |
35 | | -] : [ |
36 | | -// Plugins that apply in production builds only |
37 | | -newwebpack.optimize.OccurenceOrderPlugin(), |
38 | | -newwebpack.optimize.UglifyJsPlugin({compress: {warnings: false}}), |
39 | | -newExtractTextPlugin('site.css') |
40 | | -]) |
| 7 | +module.exports=(env)=>{ |
| 8 | +constisDevBuild=!(env&&env.prod); |
| 9 | +return[{ |
| 10 | +stats: {modules: false}, |
| 11 | +entry: {'main': './ClientApp/boot.ts'}, |
| 12 | +resolve: {extensions: ['.js','.ts']}, |
| 13 | +output: { |
| 14 | +path: path.join(__dirname,bundleOutputDir), |
| 15 | +filename: '[name].js', |
| 16 | +publicPath: '/dist/' |
| 17 | +}, |
| 18 | +module: { |
| 19 | +rules: [ |
| 20 | +{test: /\.ts$/,include: /ClientApp/,use: 'awesome-typescript-loader?silent=true'}, |
| 21 | +{test: /\.html$/,loader: 'raw-loader'}, |
| 22 | +{test: /\.css$/,loader: isDevBuild ? 'style-loader!css-loader' : ExtractTextPlugin.extract({loader: 'css-loader'})}, |
| 23 | +{test: /\.(png|jpg|jpeg|gif|svg)$/,loader: 'url-loader?limit=25000'} |
| 24 | +] |
| 25 | +}, |
| 26 | +plugins: [ |
| 27 | +newCheckerPlugin(), |
| 28 | +newwebpack.DllReferencePlugin({ |
| 29 | +context: __dirname, |
| 30 | +manifest: require('./wwwroot/dist/vendor-manifest.json') |
| 31 | +}) |
| 32 | +].concat(isDevBuild ? [ |
| 33 | +// Plugins that apply in development builds only |
| 34 | +newwebpack.SourceMapDevToolPlugin({ |
| 35 | +filename: '[file].map',// Remove this line if you prefer inline source maps |
| 36 | +moduleFilenameTemplate: path.relative(bundleOutputDir,'[resourcePath]')// Point sourcemap entries to the original file locations on disk |
| 37 | +}) |
| 38 | +] : [ |
| 39 | +// Plugins that apply in production builds only |
| 40 | +newwebpack.optimize.UglifyJsPlugin(), |
| 41 | +newExtractTextPlugin('site.css') |
| 42 | +]) |
| 43 | +}]; |
41 | 44 | }; |
0 commit comments