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'); |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 7 | const pkg = require('../package.json'); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 8 | const autoprefixer = require('autoprefixer'); |
| 9 | |
| 10 | module.exports = { |
| 11 | module: { |
| 12 | loaders: [ |
| 13 | { |
| 14 | test: /.json$/, |
| 15 | loaders: [ |
| 16 | 'json' |
| 17 | ] |
| 18 | }, |
| 19 | { |
| 20 | test: /\.(css|scss)$/, |
| 21 | loaders: ExtractTextPlugin.extract({ |
| 22 | fallbackLoader: 'style', |
| 23 | loader: 'css?minimize!sass!postcss' |
| 24 | }) |
| 25 | }, |
| 26 | { |
| 27 | test: /\.ts$/, |
| 28 | exclude: /node_modules/, |
| 29 | loaders: [ |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 30 | 'ng-annotate', |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 31 | 'ts' |
| 32 | ] |
| 33 | }, |
| 34 | { |
| 35 | test: /.html$/, |
| 36 | loaders: [ |
Matteo Scandolo | d62ea79 | 2016-12-22 14:02:28 -0800 | [diff] [blame] | 37 | 'html?' + JSON.stringify({ |
| 38 | attrs: ["img:src", "img:ng-src"] |
| 39 | }) |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 40 | ] |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 41 | }, |
| 42 | { |
| 43 | test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/, |
| 44 | loader: 'url-loader?limit=100000' |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 45 | } |
| 46 | ] |
| 47 | }, |
| 48 | plugins: [ |
| 49 | new webpack.optimize.OccurrenceOrderPlugin(), |
| 50 | new webpack.NoErrorsPlugin(), |
| 51 | new HtmlWebpackPlugin({ |
| 52 | template: conf.path.src('index.html') |
| 53 | }), |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 54 | new webpack.optimize.UglifyJsPlugin({ |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 55 | compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase |
| 56 | mangle: false // NOTE mangling was breaking the build |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 57 | }), |
| 58 | new ExtractTextPlugin('index-[contenthash].css'), |
| 59 | new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}) |
| 60 | ], |
| 61 | postcss: () => [autoprefixer], |
| 62 | output: { |
| 63 | path: path.join(process.cwd(), conf.paths.dist), |
Matteo Scandolo | f4b8517 | 2017-01-11 09:56:02 -0800 | [diff] [blame] | 64 | publicPath: "/spa/", // enable apache proxying on the head node |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 65 | filename: '[name]-[hash].js' |
| 66 | }, |
| 67 | resolve: { |
| 68 | extensions: [ |
| 69 | '', |
| 70 | '.webpack.js', |
| 71 | '.web.js', |
| 72 | '.js', |
| 73 | '.ts' |
| 74 | ] |
| 75 | }, |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 76 | entry: { |
| 77 | app: `./${conf.path.src('index')}`, |
| 78 | vendor: Object.keys(pkg.dependencies) |
| 79 | }, |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 80 | ts: { |
| 81 | configFileName: 'tsconfig.json' |
| 82 | }, |
| 83 | tslint: { |
| 84 | configuration: require('../tslint.json') |
| 85 | } |
| 86 | }; |