forked from ushahidi/platform-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
120 lines (118 loc) · 2.91 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
116
117
118
119
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var imgPath = path.resolve('node_modules/ushahidi-platform-pattern-library/assets/');
var GIT_COMMIT;
// Try to get the current GIT COMMIT
try {
GIT_COMMIT = require('child_process').execSync('git rev-parse HEAD').toString().trim();
} catch (e) {
GIT_COMMIT = process.env.CI_COMMIT_ID || null;
}
module.exports = {
devtool: 'source-map',
entry: {'app': [
'babel-polyfill'
]},
module: {
rules: [
{
type:'javascript/auto',
test: /\.js$/,
exclude: [/app\/lib/, /node_modules/],
use: [
'ng-annotate-loader',
{
loader: 'babel-loader',
options: {
presets: [
['es2015', { modules: false }],
'stage-0'
]
}
}
]
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options : {
attrs : ['img:src','use:xlink:href','link:href'],
root: imgPath
}
}
]
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'resolve-url-loader', 'sass-loader?sourceMap']
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.png/,
use: {
loader: 'url-loader?limit=10000',
options: {
esModule:false
}
}
},
{
test: /\.svg/,
use: {
loader: 'svg-url-loader?limit=1',
options: {
esModule: false
}
}
},
{
test: /\.woff/,
use: 'url-loader?limit=10000'
},
{
test: /\.ttf|\.eot/,
use: 'file-loader'
},
{
type: 'javascript/auto',
test: /manifest\.json$/,
use: [
{
loader: 'file-loader',
options: {
name: 'manifest.json'
}
}
]
}
]
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
plugins: [
new MiniCssExtractPlugin(),
// Skip locales
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
BACKEND_URL: JSON.stringify(process.env.BACKEND_URL || 'http://backend.url.undefined'),
ENVIRONMENT: JSON.stringify(process.env.ENVIRONMENT || 'dev'),
VERIFIER: JSON.stringify(process.env.VERIFIER || false),
GIT_COMMIT: JSON.stringify(GIT_COMMIT || false),
USH_DISABLE_CHECKS: JSON.stringify(process.env.USH_DISABLE_CHECKS) || false
}),
// Injects bundles in your index.html instead of wiring all manually.
new HtmlWebpackPlugin({
template: 'app/index.html'
})
]
}