forked from unhcr-jordan/services-advisor
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.config.js
115 lines (111 loc) · 3.79 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const webpack = require('webpack');
const Path = require('path');
const process = require('process');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Visualizer = require('webpack-visualizer-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
const NODE_ENV = process.env.NODE_ENV;
const extractCSSPlugin = new ExtractTextPlugin({
filename: 'css/[name].[chunkhash].css',
allChunks: true
});
module.exports = {
entry: {
app: [
"babel-polyfill",
Path.join(__dirname, 'src/angular/app.js')
]
},
output: {
filename: 'js/[name].[chunkhash].js',
path: Path.join(__dirname, 'web'),
publicPath: '/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/],
loader: "babel-loader",
},
{
test: /\.(eot|woff2|woff|ttf)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]',
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: extractCSSPlugin.extract([
{loader: 'css-loader', options: {
url: false,
sourceMap: true
}},
{loader: 'sass-loader', options: {
sourceMap: true
}}
])
}
]
},
plugins: [
new ManifestPlugin(),
new CopyWebpackPlugin([
// copy-fonts
{context: 'src/fonts', from: '**/*', to: 'fonts'},
// copy-images
{context: 'src/images', from: '**.*', to: 'images'},
// copy-html-views
{context: 'src/angular/Views', from: '**/*', to: 'views'},
// copy-polygons
{from: 'src/polygons.json'},
// copy-libs
{context: 'node_modules', from: 'angular-translate-loader-static-files/**', to: 'libs'},
{context: 'node_modules', from: 'drmonty-leaflet-awesome-markers/**', to: 'libs'},
{context: 'node_modules', from: 'Humanitarian-Font/**', to: 'libs'},
{context: 'node_modules', from: 'leaflet.markercluster/**', to: 'libs'},
{context: 'node_modules', from: 'mapbox.js/**', to: 'libs'},
{context: 'node_modules', from: 'ngPrint/**', to: 'libs'}
], {
debug: 'warning'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
if (module.context) {
return module.context.indexOf('node_modules') !== -1 || module.context.indexOf('external') !== -1;
}
}
}),
extractCSSPlugin,
new HtmlWebpackPlugin({
template: 'src/index.ejs'
}),
new WebpackCleanupPlugin({
exclude: ['.htaccess', 'favicon.ico', 'humans.txt', 'robots.txt', '**/*.json', 'fonts/**/*', 'images/**/*','libs/**/*', 'views/**/*']
})
],
devServer: {
contentBase: Path.join(__dirname, "web"),
inline: true,
historyApiFallback: false,
stats: {colors: true}
},
devtool: 'source-map'
};
const bundleStatistics = new Visualizer({
filename: './bundle-stats.html'
});
if (NODE_ENV !== 'production') {
module.exports.plugins.push(bundleStatistics);
}