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