blob: 8bef911b1c50024d595bde0637adb266e591d992 [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',
Matteo Scandolo8b2370c2017-02-02 17:19:07 -080033 'resolve-url-loader',
34 'sass?sourceMap',
Matteo Scandolod819c922016-12-02 14:06:14 -080035 'postcss'
36 ]
37 },
38 {
39 test: /\.ts$/,
40 exclude: /node_modules/,
41 loaders: [
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080042 'ng-annotate',
Matteo Scandolod819c922016-12-02 14:06:14 -080043 'ts'
44 ]
45 },
46 {
47 test: /.html$/,
48 loaders: [
Matteo Scandolo99fface2016-12-21 15:37:23 -080049 'html?' + JSON.stringify({
50 attrs: ["img:src", "img:ng-src"]
51 })
Matteo Scandolod819c922016-12-02 14:06:14 -080052 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080053 },
54 {
55 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
56 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080057 }
58 ]
59 },
60 plugins: [
Matteo Scandolo828d1e82017-01-17 14:49:38 -080061 new CopyWebpackPlugin([
62 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
63 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
64 ]),
Matteo Scandolod819c922016-12-02 14:06:14 -080065 new webpack.optimize.OccurrenceOrderPlugin(),
66 new webpack.NoErrorsPlugin(),
67 new HtmlWebpackPlugin({
68 template: conf.path.src('index.html')
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080069 })
Matteo Scandolod819c922016-12-02 14:06:14 -080070 ],
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')
Matteo Scandolo266907e2016-12-20 13:41:42 -080093 },
94 stats: {
95 colors: true,
96 modules: true,
97 reasons: true,
98 errorDetails: true
Matteo Scandolod819c922016-12-02 14:06:14 -080099 }
100};