blob: c870043b31bdb1e256b6bf2e054e2e1f6561df40 [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 ExtractTextPlugin = require('extract-text-webpack-plugin');
25const pkg = require('../package.json');
26const autoprefixer = require('autoprefixer');
27const BaseHrefWebpackPlugin = require('base-href-webpack-plugin').BaseHrefWebpackPlugin;
28const CopyWebpackPlugin = require('copy-webpack-plugin');
29const env = process.env.NODE_ENV || 'production';
30const brand = process.env.BRAND || 'cord';
31
32module.exports = {
33 module: {
34 loaders: [
35 {
36 test: /.json$/,
37 loaders: [
38 'json'
39 ]
40 },
41 {
42 test: /\.(css|scss)$/,
43 loaders: ExtractTextPlugin.extract({
44 fallbackLoader: 'style',
45 loader: 'css?minimize!sass!postcss'
46 })
47 },
48 {
49 test: /\.ts$/,
50 exclude: /node_modules/,
51 loaders: [
52 'ng-annotate',
53 'ts'
54 ]
55 },
56 {
57 test: /.html$/,
58 loaders: [
59 'html?' + JSON.stringify({
60 attrs: ["img:src", "img:ng-src"]
61 })
62 ]
63 },
64 {
65 test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif|jpeg)$/,
66 loader: 'url-loader?limit=100000'
67 }
68 ]
69 },
70 plugins: [
71 new CopyWebpackPlugin([
72 { from: `./conf/app/app.config.${env}.js`, to: `app.config.js` },
73 { from: `./conf/app/style.config.${brand}.js`, to: `style.config.js` },
74 ]),
75 new webpack.optimize.OccurrenceOrderPlugin(),
76 new webpack.NoErrorsPlugin(),
77 new HtmlWebpackPlugin({
78 inject: true,
79 template: conf.path.src('index.html')
80 }),
81 new webpack.optimize.UglifyJsPlugin({
82 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
83 mangle: false // NOTE mangling was breaking the build
84 }),
85 new ExtractTextPlugin('index-[contenthash].css'),
86 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
87 new webpack.ProvidePlugin({
88 $: "jquery",
89 jQuery: "jquery"
90 }),
91 new BaseHrefWebpackPlugin({
92 baseHref: '/spa/'
93 }),
94 ],
95 postcss: () => [autoprefixer],
96 output: {
97 path: path.join(process.cwd(), conf.paths.dist),
Max Chu438cdd72017-08-16 16:00:54 -070098 publicPath: "/xos/", // enable apache proxying on the head node
Matteo Scandolofc4b37b2017-02-02 12:18:47 -080099 filename: '[name].js'
100 },
101 resolve: {
102 extensions: [
103 '',
104 '.webpack.js',
105 '.web.js',
106 '.js',
107 '.ts'
108 ]
109 },
110 entry: {
111 app: `./${conf.path.src('index')}`,
112 vendor: Object.keys(pkg.dependencies)
113 },
114 ts: {
115 configFileName: 'tsconfig.json'
116 },
117 tslint: {
118 configuration: require('../tslint.json')
119 }
120};
121