blob: 894579091aa5ee37798d0310b9a06ab1d9fc8a8f [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');
Matteo Scandoload90b992017-01-12 16:16:12 -08009const BaseHrefWebpackPlugin = require('base-href-webpack-plugin').BaseHrefWebpackPlugin;
Matteo Scandolod819c922016-12-02 14:06:14 -080010
11module.exports = {
12 module: {
13 loaders: [
14 {
15 test: /.json$/,
16 loaders: [
17 'json'
18 ]
19 },
20 {
21 test: /\.(css|scss)$/,
22 loaders: ExtractTextPlugin.extract({
23 fallbackLoader: 'style',
24 loader: 'css?minimize!sass!postcss'
25 })
26 },
27 {
28 test: /\.ts$/,
29 exclude: /node_modules/,
30 loaders: [
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080031 'ng-annotate',
Matteo Scandolod819c922016-12-02 14:06:14 -080032 'ts'
33 ]
34 },
35 {
36 test: /.html$/,
37 loaders: [
Matteo Scandolod62ea792016-12-22 14:02:28 -080038 'html?' + JSON.stringify({
39 attrs: ["img:src", "img:ng-src"]
40 })
Matteo Scandolod819c922016-12-02 14:06:14 -080041 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080042 },
43 {
44 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
45 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080046 }
47 ]
48 },
49 plugins: [
50 new webpack.optimize.OccurrenceOrderPlugin(),
51 new webpack.NoErrorsPlugin(),
52 new HtmlWebpackPlugin({
53 template: conf.path.src('index.html')
54 }),
Matteo Scandolod819c922016-12-02 14:06:14 -080055 new webpack.optimize.UglifyJsPlugin({
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080056 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
57 mangle: false // NOTE mangling was breaking the build
Matteo Scandolod819c922016-12-02 14:06:14 -080058 }),
59 new ExtractTextPlugin('index-[contenthash].css'),
Matteo Scandolo37d65092017-01-12 12:03:05 -080060 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
61 new webpack.ProvidePlugin({
62 $: "jquery",
63 jQuery: "jquery"
Matteo Scandoload90b992017-01-12 16:16:12 -080064 }),
65 new BaseHrefWebpackPlugin({
66 baseHref: '/spa/'
Matteo Scandolo37d65092017-01-12 12:03:05 -080067 })
Matteo Scandolod819c922016-12-02 14:06:14 -080068 ],
69 postcss: () => [autoprefixer],
70 output: {
71 path: path.join(process.cwd(), conf.paths.dist),
Matteo Scandolof4b85172017-01-11 09:56:02 -080072 publicPath: "/spa/", // enable apache proxying on the head node
Matteo Scandolod819c922016-12-02 14:06:14 -080073 filename: '[name]-[hash].js'
74 },
75 resolve: {
76 extensions: [
77 '',
78 '.webpack.js',
79 '.web.js',
80 '.js',
81 '.ts'
82 ]
83 },
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080084 entry: {
Matteo Scandolo08464e52017-01-17 13:35:27 -080085 config: `./${conf.path.src('app/config/style.config.ts')}`,
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080086 app: `./${conf.path.src('index')}`,
87 vendor: Object.keys(pkg.dependencies)
88 },
Matteo Scandolod819c922016-12-02 14:06:14 -080089 ts: {
90 configFileName: 'tsconfig.json'
91 },
92 tslint: {
93 configuration: require('../tslint.json')
94 }
95};
Matteo Scandolo08464e52017-01-17 13:35:27 -080096