Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 1 | const webpack = require('webpack'); |
| 2 | const conf = require('./gulp.conf'); |
| 3 | const path = require('path'); |
| 4 | |
| 5 | const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 6 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
| 7 | const autoprefixer = require('autoprefixer'); |
| 8 | |
| 9 | module.exports = { |
| 10 | module: { |
| 11 | loaders: [ |
| 12 | { |
| 13 | test: /.json$/, |
| 14 | loaders: [ |
| 15 | 'json' |
| 16 | ] |
| 17 | }, |
| 18 | { |
| 19 | test: /\.(css|scss)$/, |
| 20 | loaders: ExtractTextPlugin.extract({ |
| 21 | fallbackLoader: 'style', |
| 22 | loader: 'css?minimize!sass!postcss' |
| 23 | }) |
| 24 | }, |
| 25 | { |
| 26 | test: /\.ts$/, |
| 27 | exclude: /node_modules/, |
| 28 | loaders: [ |
| 29 | 'ts' |
| 30 | ] |
| 31 | }, |
| 32 | { |
| 33 | test: /.html$/, |
| 34 | loaders: [ |
| 35 | 'html' |
| 36 | ] |
| 37 | } |
| 38 | ] |
| 39 | }, |
| 40 | plugins: [ |
| 41 | new webpack.optimize.OccurrenceOrderPlugin(), |
| 42 | new webpack.NoErrorsPlugin(), |
| 43 | new HtmlWebpackPlugin({ |
| 44 | template: conf.path.src('index.html') |
| 45 | }), |
| 46 | new webpack.ContextReplacementPlugin( |
| 47 | /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, |
| 48 | conf.paths.src |
| 49 | ), |
| 50 | new webpack.DefinePlugin({ |
| 51 | 'process.env.NODE_ENV': '"production"' |
| 52 | }), |
| 53 | new webpack.optimize.UglifyJsPlugin({ |
| 54 | compress: {unused: true, dead_code: true, warnings: false} // eslint-disable-line camelcase |
| 55 | }), |
| 56 | new ExtractTextPlugin('index-[contenthash].css'), |
| 57 | new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}) |
| 58 | ], |
| 59 | postcss: () => [autoprefixer], |
| 60 | output: { |
| 61 | path: path.join(process.cwd(), conf.paths.dist), |
| 62 | filename: '[name]-[hash].js' |
| 63 | }, |
| 64 | resolve: { |
| 65 | extensions: [ |
| 66 | '', |
| 67 | '.webpack.js', |
| 68 | '.web.js', |
| 69 | '.js', |
| 70 | '.ts' |
| 71 | ] |
| 72 | }, |
| 73 | entry: `./${conf.path.src('index')}`, |
| 74 | ts: { |
| 75 | configFileName: 'tsconfig.json' |
| 76 | }, |
| 77 | tslint: { |
| 78 | configuration: require('../tslint.json') |
| 79 | } |
| 80 | }; |