blob: f0dbc51d458c09974114dd03777a7b67ad01c249 [file] [log] [blame]
Matteo Scandolo5461a7c2017-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 Scandolofc4b37b2017-02-02 12:18:47 -080019const 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'
Matteo Scandolo00d82ee2017-11-16 10:27:44 -0800102 ],
103 alias: {
104 "ngprogress": path.resolve(__dirname, '../node_modules/ngprogress/build/ngProgress.js')
105 }
Matteo Scandolofc4b37b2017-02-02 12:18:47 -0800106 },
107 entry: `./${conf.path.src('index')}`,
108 ts: {
109 configFileName: 'tsconfig.json'
110 },
111 tslint: {
112 configuration: require('../tslint.json')
113 },
114 stats: {
115 colors: true,
116 modules: true,
117 reasons: true,
118 errorDetails: true
119 }
120};