Updating to the optimized version
[aai/sparky-fe.git] / webpack.config.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 'use strict';
22
23 var webpack = require('webpack');
24 var path = require('path');
25
26 module.exports = {
27   devtool: 'source-map',
28   cache: 'true',
29   entry: {
30     bundle: [
31       'app/main.app.jsx',
32       'webpack/hot/only-dev-server'
33     ],
34     'editAttributes/editAttributesBundle': [
35       'editAttributes/main.app.jsx',
36       'webpack/hot/only-dev-server'
37     ]
38   },
39   output: {
40     path: path.join(__dirname, 'dist'),
41     publicPath: ``,
42     filename: '[name].js',
43     sourceMapFilename: '[name].js.map'
44   },
45   resolve: {
46     root: [path.resolve('.')],
47     alias: {
48       app: 'src/app',
49       'generic-components': 'src/generic-components',
50       utils: 'src/utils',
51       images: 'resources/images',
52       editAttributes: 'src/editAttributes'
53     },
54     extensions: ["", ".webpack.js", ".web.js", ".js", ".json", ".jsx"]
55   },
56   resolveLoader: {
57     root: [path.resolve('.')],
58     alias: {
59       'config-json-loader': 'tools/webpack/config-json-loader/index.js'
60   }
61   },
62   module: {
63     loaders: [
64       {test: /\.(js|jsx)$/, loaders: ['babel-loader', 'eslint-loader'], exclude: /node_modules/},
65       {test: /\.(css|scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']},
66       // required for font icons
67       {test: /\.(woff|woff2|ttf|eot|otf)(\?.*)?$/, loader: 'url-loader?limit=163840&mimetype=application/font-woff&name=[name].[ext]'},
68       {test: /\.(png|jpg|svg)(\?.*)?$/, loader: 'url-loader?limit=163840'},
69       {test: /\.json$/, loaders: ['json']},
70       { test: /\.xml$/, loader: 'xml-loader' }
71     ]
72   },
73   eslint: {
74     configFile: './.eslintrc',
75     failOnError: true,
76     emitError: true,
77     emitWarning: true
78   },
79   plugins: [
80     new webpack.DefinePlugin({
81       'process.env.NODE_ENV': JSON.stringify('production')
82       }),
83     new webpack.optimize.DedupePlugin(),
84     new webpack.optimize.UglifyJsPlugin({ sourceMap: true })
85   ]
86 };