blob: 5506296ec231c7c3625f561a66b0058c7c397528 [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');
Matteo Scandolo042ea632017-03-01 19:02:34 -08008const ExtractTextPlugin = require('extract-text-webpack-plugin');
Matteo Scandolo828d1e82017-01-17 14:49:38 -08009const env = process.env.NODE_ENV || 'production';
10const brand = process.env.BRAND || 'cord';
Matteo Scandolod819c922016-12-02 14:06:14 -080011
12module.exports = {
13 module: {
14 preLoaders: [
15 {
16 test: /\.ts$/,
17 exclude: /node_modules/,
18 loader: 'tslint'
19 }
20 ],
21
22 loaders: [
23 {
24 test: /.json$/,
25 loaders: [
26 'json'
27 ]
28 },
29 {
30 test: /\.(css|scss)$/,
Matteo Scandolo042ea632017-03-01 19:02:34 -080031 loaders: ExtractTextPlugin.extract({
32 fallbackLoader: 'style',
33 loader: [
34 'css',
35 'resolve-url-loader',
36 'sass?sourceMap',
37 'postcss'
38 ]
39 })
Matteo Scandolod819c922016-12-02 14:06:14 -080040 },
41 {
42 test: /\.ts$/,
43 exclude: /node_modules/,
44 loaders: [
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080045 'ng-annotate',
Matteo Scandolod819c922016-12-02 14:06:14 -080046 'ts'
47 ]
48 },
49 {
50 test: /.html$/,
51 loaders: [
Matteo Scandolo99fface2016-12-21 15:37:23 -080052 'html?' + JSON.stringify({
53 attrs: ["img:src", "img:ng-src"]
54 })
Matteo Scandolod819c922016-12-02 14:06:14 -080055 ]
Matteo Scandolo266907e2016-12-20 13:41:42 -080056 },
57 {
58 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
59 loader: 'url-loader?limit=100000'
Matteo Scandolod819c922016-12-02 14:06:14 -080060 }
61 ]
62 },
63 plugins: [
Matteo Scandolo828d1e82017-01-17 14:49:38 -080064 new CopyWebpackPlugin([
65 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
66 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
67 ]),
Matteo Scandolod819c922016-12-02 14:06:14 -080068 new webpack.optimize.OccurrenceOrderPlugin(),
69 new webpack.NoErrorsPlugin(),
70 new HtmlWebpackPlugin({
71 template: conf.path.src('index.html')
Matteo Scandolo042ea632017-03-01 19:02:34 -080072 }),
73 new ExtractTextPlugin('index-[contenthash].css'),
Matteo Scandolod819c922016-12-02 14:06:14 -080074 ],
75 postcss: () => [autoprefixer],
76 debug: true,
77 devtool: 'source-map',
78 output: {
79 path: path.join(process.cwd(), conf.paths.tmp),
Matteo Scandolo042ea632017-03-01 19:02:34 -080080 filename: '[name].js'
Matteo Scandolod819c922016-12-02 14:06:14 -080081 },
82 resolve: {
83 extensions: [
84 '',
85 '.webpack.js',
86 '.web.js',
87 '.js',
88 '.ts'
89 ]
90 },
Matteo Scandolo042ea632017-03-01 19:02:34 -080091 entry: {
92 indes: `./${conf.path.src('index')}`,
93 loader: `./${conf.path.src('/app/style/imports/loader.scss')}`
94 },
Matteo Scandolod819c922016-12-02 14:06:14 -080095 ts: {
96 configFileName: 'tsconfig.json'
97 },
98 tslint: {
99 configuration: require('../tslint.json')
Matteo Scandolo266907e2016-12-20 13:41:42 -0800100 },
101 stats: {
102 colors: true,
103 modules: true,
104 reasons: true,
105 errorDetails: true
Matteo Scandolod819c922016-12-02 14:06:14 -0800106 }
107};