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 autoprefixer = require('autoprefixer'); |
Matteo Scandolo | 828d1e8 | 2017-01-17 14:49:38 -0800 | [diff] [blame] | 7 | const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 8 | const env = process.env.NODE_ENV || 'production'; |
| 9 | const brand = process.env.BRAND || 'cord'; |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 10 | |
| 11 | module.exports = { |
| 12 | module: { |
| 13 | preLoaders: [ |
| 14 | { |
| 15 | test: /\.ts$/, |
| 16 | exclude: /node_modules/, |
| 17 | loader: 'tslint' |
| 18 | } |
| 19 | ], |
| 20 | |
| 21 | loaders: [ |
| 22 | { |
| 23 | test: /.json$/, |
| 24 | loaders: [ |
| 25 | 'json' |
| 26 | ] |
| 27 | }, |
| 28 | { |
| 29 | test: /\.(css|scss)$/, |
| 30 | loaders: [ |
| 31 | 'style', |
| 32 | 'css', |
| 33 | 'sass', |
| 34 | 'postcss' |
| 35 | ] |
| 36 | }, |
| 37 | { |
| 38 | test: /\.ts$/, |
| 39 | exclude: /node_modules/, |
| 40 | loaders: [ |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 41 | 'ng-annotate', |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 42 | 'ts' |
| 43 | ] |
| 44 | }, |
| 45 | { |
| 46 | test: /.html$/, |
| 47 | loaders: [ |
Matteo Scandolo | 99fface | 2016-12-21 15:37:23 -0800 | [diff] [blame] | 48 | 'html?' + JSON.stringify({ |
| 49 | attrs: ["img:src", "img:ng-src"] |
| 50 | }) |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 51 | ] |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 52 | }, |
| 53 | { |
| 54 | test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/, |
| 55 | loader: 'url-loader?limit=100000' |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 56 | } |
| 57 | ] |
| 58 | }, |
| 59 | plugins: [ |
Matteo Scandolo | 828d1e8 | 2017-01-17 14:49:38 -0800 | [diff] [blame] | 60 | new CopyWebpackPlugin([ |
| 61 | { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` }, |
| 62 | { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` }, |
| 63 | ]), |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 64 | new webpack.optimize.OccurrenceOrderPlugin(), |
| 65 | new webpack.NoErrorsPlugin(), |
| 66 | new HtmlWebpackPlugin({ |
| 67 | template: conf.path.src('index.html') |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 68 | }) |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 69 | ], |
| 70 | postcss: () => [autoprefixer], |
| 71 | debug: true, |
| 72 | devtool: 'source-map', |
| 73 | output: { |
| 74 | path: path.join(process.cwd(), conf.paths.tmp), |
| 75 | filename: 'index.js' |
| 76 | }, |
| 77 | resolve: { |
| 78 | extensions: [ |
| 79 | '', |
| 80 | '.webpack.js', |
| 81 | '.web.js', |
| 82 | '.js', |
| 83 | '.ts' |
| 84 | ] |
| 85 | }, |
| 86 | entry: `./${conf.path.src('index')}`, |
| 87 | ts: { |
| 88 | configFileName: 'tsconfig.json' |
| 89 | }, |
| 90 | tslint: { |
| 91 | configuration: require('../tslint.json') |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame] | 92 | }, |
| 93 | stats: { |
| 94 | colors: true, |
| 95 | modules: true, |
| 96 | reasons: true, |
| 97 | errorDetails: true |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 98 | } |
| 99 | }; |