blob: 59bb335e5110661db13cb07b070bc17c8754f230 [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001const webpack = require('webpack');
2const conf = require('./gulp.conf');
3const path = require('path');
4
5const HtmlWebpackPlugin = require('html-webpack-plugin');
6const ExtractTextPlugin = require('extract-text-webpack-plugin');
Matteo Scandolof6acdbe2016-12-13 10:29:37 -08007const pkg = require('../package.json');
Matteo Scandolod819c922016-12-02 14:06:14 -08008const autoprefixer = require('autoprefixer');
9
10module.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 Scandolof6acdbe2016-12-13 10:29:37 -080030 'ng-annotate',
Matteo Scandolod819c922016-12-02 14:06:14 -080031 'ts'
32 ]
33 },
34 {
35 test: /.html$/,
36 loaders: [
37 'html'
38 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080039 },
40 {
41 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
42 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080043 }
44 ]
45 },
46 plugins: [
47 new webpack.optimize.OccurrenceOrderPlugin(),
48 new webpack.NoErrorsPlugin(),
49 new HtmlWebpackPlugin({
50 template: conf.path.src('index.html')
51 }),
Matteo Scandolod819c922016-12-02 14:06:14 -080052 new webpack.optimize.UglifyJsPlugin({
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080053 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
54 mangle: false // NOTE mangling was breaking the build
Matteo Scandolod819c922016-12-02 14:06:14 -080055 }),
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 },
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080073 entry: {
74 app: `./${conf.path.src('index')}`,
75 vendor: Object.keys(pkg.dependencies)
76 },
Matteo Scandolod819c922016-12-02 14:06:14 -080077 ts: {
78 configFileName: 'tsconfig.json'
79 },
80 tslint: {
81 configuration: require('../tslint.json')
82 }
83};