blob: 33f0acbba5842da4d8dcdf91ee2f3fa5d90d5cf2 [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 ]
39 }
40 ]
41 },
42 plugins: [
43 new webpack.optimize.OccurrenceOrderPlugin(),
44 new webpack.NoErrorsPlugin(),
45 new HtmlWebpackPlugin({
46 template: conf.path.src('index.html')
47 }),
Matteo Scandolod819c922016-12-02 14:06:14 -080048 new webpack.optimize.UglifyJsPlugin({
49 compress: {unused: true, dead_code: true, warnings: false} // eslint-disable-line camelcase
50 }),
51 new ExtractTextPlugin('index-[contenthash].css'),
52 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'})
53 ],
54 postcss: () => [autoprefixer],
55 output: {
56 path: path.join(process.cwd(), conf.paths.dist),
57 filename: '[name]-[hash].js'
58 },
59 resolve: {
60 extensions: [
61 '',
62 '.webpack.js',
63 '.web.js',
64 '.js',
65 '.ts'
66 ]
67 },
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080068 entry: {
69 app: `./${conf.path.src('index')}`,
70 vendor: Object.keys(pkg.dependencies)
71 },
Matteo Scandolod819c922016-12-02 14:06:14 -080072 ts: {
73 configFileName: 'tsconfig.json'
74 },
75 tslint: {
76 configuration: require('../tslint.json')
77 }
78};