blob: 91dd0a7e672a4b1ba3a393488e918c1cbbb7245a [file] [log] [blame]
Matteo Scandoloe19fa102017-03-09 15:38:59 -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');
7const pkg = require('../package.json');
8const autoprefixer = require('autoprefixer');
9const BaseHrefWebpackPlugin = require('base-href-webpack-plugin').BaseHrefWebpackPlugin;
10const CopyWebpackPlugin = require('copy-webpack-plugin');
11const env = process.env.NODE_ENV || 'production';
12const brand = process.env.BRAND || 'cord';
13
14module.exports = {
15 module: {
16 loaders: [
17 {
18 test: /.json$/,
19 loaders: [
20 'json'
21 ]
22 },
23 {
24 test: /\.(css|scss)$/,
25 loaders: ExtractTextPlugin.extract({
26 fallbackLoader: 'style',
27 loader: 'css?minimize!sass!postcss'
28 })
29 },
30 {
31 test: /\.ts$/,
32 exclude: /node_modules/,
33 loaders: [
34 'ng-annotate',
35 'ts'
36 ]
37 },
38 {
39 test: /.html$/,
40 loaders: [
41 'html?' + JSON.stringify({
42 attrs: ["img:src", "img:ng-src"]
43 })
44 ]
45 },
46 {
47 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
48 loader: 'url-loader?limit=100000'
49 }
50 ]
51 },
52 plugins: [
53 new CopyWebpackPlugin([
54 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
55 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
56 ]),
57 new webpack.optimize.OccurrenceOrderPlugin(),
58 new webpack.NoErrorsPlugin(),
59 new HtmlWebpackPlugin({
60 inject: true,
61 template: conf.path.src('index.html')
62 }),
63 new webpack.optimize.UglifyJsPlugin({
64 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
65 mangle: false // NOTE mangling was breaking the build
66 }),
67 new ExtractTextPlugin('index-[contenthash].css'),
68 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
69 new webpack.ProvidePlugin({
70 $: "jquery",
71 jQuery: "jquery"
72 }),
73 new BaseHrefWebpackPlugin({
74 baseHref: '/spa/'
75 }),
76 ],
77 postcss: () => [autoprefixer],
78 output: {
79 path: path.join(process.cwd(), conf.paths.dist),
80 publicPath: "/spa/", // enable apache proxying on the head node
81 filename: '[name].js'
82 },
83 resolve: {
84 extensions: [
85 '',
86 '.webpack.js',
87 '.web.js',
88 '.js',
89 '.ts'
90 ]
91 },
92 entry: {
93 app: `./${conf.path.src('index')}`,
94 vendor: Object.keys(pkg.dependencies)
95 },
96 ts: {
97 configFileName: 'tsconfig.json'
98 },
99 tslint: {
100 configuration: require('../tslint.json')
101 }
102};
103