blob: 0a16b7d7e3e861070fee93647b49ca2aa063a876 [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 autoprefixer = require('autoprefixer');
7const CopyWebpackPlugin = require('copy-webpack-plugin');
8const env = process.env.NODE_ENV || 'production';
9const brand = process.env.BRAND || 'cord';
10
11module.exports = {
12 module: {
13 preLoaders: [
14 {
15 test: /\.ts$/,
16 exclude: /node_modules/,
17 loader: 'tslint'
18 }
19 ],
20
21 loaders: [
22 {
23 test: /.json$/,
24 loaders: [
25 'json'
26 ]
27 },
28 {
29 test: /\.(css|scss)$/,
30 loaders: [
31 'style',
32 'css',
33 'sass',
34 'postcss'
35 ]
36 },
37 {
38 test: /\.ts$/,
39 exclude: /node_modules/,
40 loaders: [
41 'ng-annotate',
42 'ts'
43 ]
44 },
45 {
46 test: /.html$/,
47 loaders: [
48 'html?' + JSON.stringify({
49 attrs: ["img:src", "img:ng-src"]
50 })
51 ]
52 },
53 {
54 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
55 loader: 'url-loader?limit=100000'
56 }
57 ]
58 },
59 plugins: [
60 new CopyWebpackPlugin([
61 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
62 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
63 { from: `./conf/app/mapconstants.local.js`, to: `mapconstants.js`}
64 ]),
65 new webpack.optimize.OccurrenceOrderPlugin(),
66 new webpack.NoErrorsPlugin(),
67 new HtmlWebpackPlugin({
68 template: conf.path.src('index.html')
69 })
70 ],
71 postcss: () => [autoprefixer],
72 debug: true,
73 devtool: 'source-map',
74 output: {
75 path: path.join(process.cwd(), conf.paths.tmp),
76 filename: 'index.js'
77 },
78 resolve: {
79 extensions: [
80 '',
81 '.webpack.js',
82 '.web.js',
83 '.js',
84 '.ts'
85 ]
86 },
87 entry: `./${conf.path.src('index')}`,
88 ts: {
89 configFileName: 'tsconfig.json'
90 },
91 tslint: {
92 configuration: require('../tslint.json')
93 },
94 stats: {
95 colors: true,
96 modules: true,
97 reasons: true,
98 errorDetails: true
99 }
100};