blob: bde734300ed429ecb37b8d2d3c45979ff6fa6caa [file] [log] [blame]
Max Chu3c8b65f2017-07-19 17:47:59 -07001const 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 { from: `./conf/app/mapconstants.production.js`, to: `mapconstants.js`}
57 ]),
58 new webpack.optimize.OccurrenceOrderPlugin(),
59 new webpack.NoErrorsPlugin(),
60 new HtmlWebpackPlugin({
61 inject: true,
62 template: conf.path.src('index.html')
63 }),
64 new webpack.optimize.UglifyJsPlugin({
65 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
66 mangle: false // NOTE mangling was breaking the build
67 }),
Max Chudafc0ba2017-08-15 11:03:09 -070068 new ExtractTextPlugin('index.css'),
Max Chu3c8b65f2017-07-19 17:47:59 -070069 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
70 new webpack.ProvidePlugin({
71 $: "jquery",
72 jQuery: "jquery"
73 }),
74 new BaseHrefWebpackPlugin({
75 baseHref: '/xos/'
76 }),
77 ],
78 postcss: () => [autoprefixer],
79 output: {
80 path: path.join(process.cwd(), conf.paths.dist),
81 publicPath: "/xos/", // enable apache proxying on the head node
82 filename: '[name].js'
83 },
84 resolve: {
85 extensions: [
86 '',
87 '.webpack.js',
88 '.web.js',
89 '.js',
90 '.ts'
91 ],
92 alias: {
93 "ngprogress": path.resolve(__dirname, '../node_modules/ngprogress/build/ngProgress.js')
94 }
95 },
96 entry: {
97 app: `./${conf.path.src('index')}`,
98 vendor: Object.keys(pkg.dependencies)
99 },
100 ts: {
101 configFileName: 'tsconfig.json'
102 },
103 tslint: {
104 configuration: require('../tslint.json')
105 }
106};
107