|
1 |
| -var isDevBuild = process.argv.indexOf('--env.prod') < 0; |
2 |
| -var path = require('path'); |
3 |
| -var webpack = require('webpack'); |
4 |
| -var ExtractTextPlugin = require('extract-text-webpack-plugin'); |
| 1 | +const path = require('path'); |
| 2 | +const webpack = require('webpack'); |
| 3 | +const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
| 4 | +const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin; |
| 5 | +const bundleOutputDir = './wwwroot/dist'; |
5 | 6 |
|
6 |
| -var bundleOutputDir = './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 |
| - new webpack.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 |
| - new webpack.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 |
| - new webpack.optimize.OccurenceOrderPlugin(), |
38 |
| - new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), |
39 |
| - new ExtractTextPlugin('site.css') |
40 |
| - ]) |
| 7 | +module.exports = (env) => { |
| 8 | + const isDevBuild = !(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 | + new CheckerPlugin(), |
| 28 | + new webpack.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 | + new webpack.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 | + new webpack.optimize.UglifyJsPlugin(), |
| 41 | + new ExtractTextPlugin('site.css') |
| 42 | + ]) |
| 43 | + }]; |
41 | 44 | };
|
0 commit comments