blob: 544b2c5115f4f750903cbb98786b8d87701ba086 [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 autoprefixer = require('autoprefixer');
Matteo Scandolo828d1e82017-01-17 14:49:38 -08007const CopyWebpackPlugin = require('copy-webpack-plugin');
8const env = process.env.NODE_ENV || 'production';
9const brand = process.env.BRAND || 'cord';
Matteo Scandolod819c922016-12-02 14:06:14 -080010
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: [
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080041 'ng-annotate',
Matteo Scandolod819c922016-12-02 14:06:14 -080042 'ts'
43 ]
44 },
45 {
46 test: /.html$/,
47 loaders: [
Matteo Scandolo99fface2016-12-21 15:37:23 -080048 'html?' + JSON.stringify({
49 attrs: ["img:src", "img:ng-src"]
50 })
Matteo Scandolod819c922016-12-02 14:06:14 -080051 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080052 },
53 {
54 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
55 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080056 }
57 ]
58 },
59 plugins: [
Matteo Scandolo828d1e82017-01-17 14:49:38 -080060 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 ]),
Matteo Scandolod819c922016-12-02 14:06:14 -080064 new webpack.optimize.OccurrenceOrderPlugin(),
65 new webpack.NoErrorsPlugin(),
66 new HtmlWebpackPlugin({
67 template: conf.path.src('index.html')
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080068 })
Matteo Scandolod819c922016-12-02 14:06:14 -080069 ],
70 postcss: () => [autoprefixer],
71 debug: true,
72 devtool: 'source-map',
73 output: {
74 path: path.join(process.cwd(), conf.paths.tmp),
75 filename: 'index.js'
76 },
77 resolve: {
78 extensions: [
79 '',
80 '.webpack.js',
81 '.web.js',
82 '.js',
83 '.ts'
84 ]
85 },
86 entry: `./${conf.path.src('index')}`,
87 ts: {
88 configFileName: 'tsconfig.json'
89 },
90 tslint: {
91 configuration: require('../tslint.json')
Matteo Scandolo266907e2016-12-20 13:41:42 -080092 },
93 stats: {
94 colors: true,
95 modules: true,
96 reasons: true,
97 errorDetails: true
Matteo Scandolod819c922016-12-02 14:06:14 -080098 }
99};