blob: a59ff693727fc86c7debca49d07f8c05bd40b566 [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: [
Matteo Scandolod62ea792016-12-22 14:02:28 -080037 'html?' + JSON.stringify({
38 attrs: ["img:src", "img:ng-src"]
39 })
Matteo Scandolod819c922016-12-02 14:06:14 -080040 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080041 },
42 {
43 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
44 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080045 }
46 ]
47 },
48 plugins: [
49 new webpack.optimize.OccurrenceOrderPlugin(),
50 new webpack.NoErrorsPlugin(),
51 new HtmlWebpackPlugin({
52 template: conf.path.src('index.html')
53 }),
Matteo Scandolod819c922016-12-02 14:06:14 -080054 new webpack.optimize.UglifyJsPlugin({
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080055 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
56 mangle: false // NOTE mangling was breaking the build
Matteo Scandolod819c922016-12-02 14:06:14 -080057 }),
58 new ExtractTextPlugin('index-[contenthash].css'),
Matteo Scandolo37d65092017-01-12 12:03:05 -080059 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
60 new webpack.ProvidePlugin({
61 $: "jquery",
62 jQuery: "jquery"
63 })
Matteo Scandolod819c922016-12-02 14:06:14 -080064 ],
65 postcss: () => [autoprefixer],
66 output: {
67 path: path.join(process.cwd(), conf.paths.dist),
Matteo Scandolof4b85172017-01-11 09:56:02 -080068 publicPath: "/spa/", // enable apache proxying on the head node
Matteo Scandolod819c922016-12-02 14:06:14 -080069 filename: '[name]-[hash].js'
70 },
71 resolve: {
72 extensions: [
73 '',
74 '.webpack.js',
75 '.web.js',
76 '.js',
77 '.ts'
78 ]
79 },
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080080 entry: {
81 app: `./${conf.path.src('index')}`,
82 vendor: Object.keys(pkg.dependencies)
83 },
Matteo Scandolod819c922016-12-02 14:06:14 -080084 ts: {
85 configFileName: 'tsconfig.json'
86 },
87 tslint: {
88 configuration: require('../tslint.json')
89 }
90};