Initialize the UI code
[holmes/rule-management.git] / rulemgt / src / main / frontend / src / config / webpack.prod.js
1 /* Copyright 2017 ZTE Corporation.
2  *
3  *Licensed under the Apache License, Version 2.0 (the "License");
4  *you may not use this file except in compliance with the License.
5  *You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 const ExtractTextPlugin = require('extract-text-webpack-plugin');
16 const DefinePlugin = require('webpack/lib/DefinePlugin');
17 const CopyWebpackPlugin = require('copy-webpack-plugin');
18 const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
19 const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
20
21
22 const webpack = require('webpack');
23 const commonConfig = require('./webpack.common.js');
24 const webpackMerge = require('webpack-merge');
25 const helpers = require('./helpers');
26
27
28 module.exports = webpackMerge(commonConfig, {
29  
30
31   devtool: 'source-map',
32
33  
34   output: {
35   
36     path: helpers.root('holmes'),
37     
38     filename: '[name].[chunkhash].bundle.js',//'[name].[hash].js',
39
40     sourceMapFilename: '[name].[chunkhash].bundle.map',
41
42     
43     chunkFilename: '[id].[chunkhash].chunk.js'//'[id].[hash].chunk.js'
44   },
45
46
47
48
49   module: {
50
51     rules: [
52     
53       {
54         test: /\.css$/,
55         loader: ExtractTextPlugin.extract({
56           fallback: 'style-loader',
57           use: {
58             loader: 'css-loader',
59             options: {
60               sourceMap: true,
61               minimize: true
62             }
63           }
64         }),
65         include: [helpers.root('alarm/assets'), helpers.root('public'),helpers.root('alarm/app')]
66       },
67     ]
68
69   },
70
71   plugins: [
72
73     new webpack.NoErrorsPlugin(),
74
75     new webpack.optimize.DedupePlugin(),
76
77     new webpack.optimize.UglifyJsPlugin({
78       sourceMap: true,
79       mangle: {
80         keep_fnames: true
81       }
82     }),
83
84    
85     new ExtractTextPlugin('[name].[contenthash].css'),
86     
87     new DefinePlugin({
88       'CONST': true,
89     }),
90
91    
92     new LoaderOptionsPlugin({
93       minimize: true,
94       debug: false,
95     })
96   ],
97
98
99   node: {
100     global: true,
101     crypto: 'empty',
102     process: false,
103     module: false,
104     clearImmediate: false,
105     setImmediate: false
106   }
107
108
109 });