blob: d70e7718a29eff4259b220b01c47e4b68adca6fc [file] [log] [blame]
Matteo Scandolof0446ed2017-08-08 13:05:24 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
Matteo Scandoloc46a82d2017-03-24 18:37:18 -070019const webpack = require('webpack');
20const conf = require('./gulp.conf');
21const path = require('path');
22
23const HtmlWebpackPlugin = require('html-webpack-plugin');
24const autoprefixer = require('autoprefixer');
25const CopyWebpackPlugin = require('copy-webpack-plugin');
26const env = process.env.NODE_ENV || 'production';
27const brand = process.env.BRAND || 'cord';
28
29module.exports = {
30 module: {
31 preLoaders: [
32 {
33 test: /\.ts$/,
34 exclude: /node_modules/,
35 loader: 'tslint'
36 }
37 ],
38
39 loaders: [
40 {
41 test: /.json$/,
42 loaders: [
43 'json'
44 ]
45 },
46 {
47 test: /\.(css|scss)$/,
48 loaders: [
49 'style',
50 'css',
51 'sass',
52 'postcss'
53 ]
54 },
55 {
56 test: /\.ts$/,
57 exclude: /node_modules/,
58 loaders: [
59 'ng-annotate',
60 'ts'
61 ]
62 },
63 {
64 test: /.html$/,
65 loaders: [
66 'html?' + JSON.stringify({
67 attrs: ["img:src", "img:ng-src"]
68 })
69 ]
70 },
71 {
72 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
73 loader: 'url-loader?limit=100000'
74 }
75 ]
76 },
77 plugins: [
78 new CopyWebpackPlugin([
79 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
80 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
81 ]),
82 new webpack.optimize.OccurrenceOrderPlugin(),
83 new webpack.NoErrorsPlugin(),
84 new HtmlWebpackPlugin({
85 template: conf.path.src('index.html')
86 })
87 ],
88 postcss: () => [autoprefixer],
89 debug: true,
90 devtool: 'source-map',
91 output: {
92 path: path.join(process.cwd(), conf.paths.tmp),
93 filename: 'index.js'
94 },
95 resolve: {
96 extensions: [
97 '',
98 '.webpack.js',
99 '.web.js',
100 '.js',
101 '.ts'
102 ]
103 },
104 entry: `./${conf.path.src('index')}`,
105 ts: {
106 configFileName: 'tsconfig.json'
107 },
108 tslint: {
109 configuration: require('../tslint.json')
110 },
111 stats: {
112 colors: true,
113 modules: true,
114 reasons: true,
115 errorDetails: true
116 }
117};