blob: d0f531f9f3e01e9606701c1f2a4c862346eea512 [file] [log] [blame]
Andrea Campanella95c02bd2017-09-01 16:51:03 +02001
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
19const 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 { from: `./conf/app/mapconstants.production.js`, to: `mapconstants.js`}
75 ]),
76 new webpack.optimize.OccurrenceOrderPlugin(),
77 new webpack.NoErrorsPlugin(),
78 new HtmlWebpackPlugin({
79 inject: true,
80 template: conf.path.src('index.html')
81 }),
82 new webpack.optimize.UglifyJsPlugin({
83 compress: {unused: true, dead_code: true, warnings: false}, // eslint-disable-line camelcase
84 mangle: false // NOTE mangling was breaking the build
85 }),
86 new ExtractTextPlugin('index-[contenthash].css'),
87 new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
88 new webpack.ProvidePlugin({
89 $: "jquery",
90 jQuery: "jquery"
91 }),
92 new BaseHrefWebpackPlugin({
93 baseHref: '/xos/'
94 }),
95 ],
96 postcss: () => [autoprefixer],
97 output: {
98 path: path.join(process.cwd(), conf.paths.dist),
99 publicPath: "/xos/", // enable apache proxying on the head node
100 filename: '[name].js'
101 },
102 resolve: {
103 extensions: [
104 '',
105 '.webpack.js',
106 '.web.js',
107 '.js',
108 '.ts'
109 ],
Matteo Scandolo204811e2017-11-16 13:24:15 -0800110 alias: {
111 "ngprogress": path.resolve(__dirname, '../node_modules/ngprogress/build/ngProgress.js')
112 }
Andrea Campanella95c02bd2017-09-01 16:51:03 +0200113 },
114 entry: {
115 app: `./${conf.path.src('index')}`,
116 vendor: Object.keys(pkg.dependencies)
117 },
118 ts: {
119 configFileName: 'tsconfig.json'
120 },
121 tslint: {
122 configuration: require('../tslint.json')
123 }
124};
125