Matteo Scandolo | c46a82d | 2017-03-24 18:37:18 -0700 | [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'); |
| 7 | const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 8 | const env = process.env.NODE_ENV || 'production'; |
| 9 | const brand = process.env.BRAND || 'cord'; |
| 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: [ |
| 41 | 'ng-annotate', |
| 42 | 'ts' |
| 43 | ] |
| 44 | }, |
| 45 | { |
| 46 | test: /.html$/, |
| 47 | loaders: [ |
| 48 | 'html?' + JSON.stringify({ |
| 49 | attrs: ["img:src", "img:ng-src"] |
| 50 | }) |
| 51 | ] |
| 52 | }, |
| 53 | { |
| 54 | test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/, |
| 55 | loader: 'url-loader?limit=100000' |
| 56 | } |
| 57 | ] |
| 58 | }, |
| 59 | plugins: [ |
| 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 | ]), |
| 64 | new webpack.optimize.OccurrenceOrderPlugin(), |
| 65 | new webpack.NoErrorsPlugin(), |
| 66 | new HtmlWebpackPlugin({ |
| 67 | template: conf.path.src('index.html') |
| 68 | }) |
| 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') |
| 92 | }, |
| 93 | stats: { |
| 94 | colors: true, |
| 95 | modules: true, |
| 96 | reasons: true, |
| 97 | errorDetails: true |
| 98 | } |
| 99 | }; |