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