-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
97 lines (91 loc) · 1.75 KB
/
webpack.config.js
File metadata and controls
97 lines (91 loc) · 1.75 KB
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
// Modules
var webpack = require('webpack');
var path = require('path');
/**
* Env
* Get npm lifecycle event to identify the environment
*/
var ENV = process.env.npm_lifecycle_event;
var isProd = ENV === 'build';
var config = {
entry: {
script: [
'babel-polyfill',
'./scripts/api-explorer/v2/src/main.es6.js'
]
},
output: {
path: path.join(__dirname, './scripts/api-explorer/v2/'),
filename: '[name].js',
library: "base" // global variable
},
devtool: isProd ? 'none' : 'inline-source-map',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, "scripts"),
],
query: {
presets: [
"es2015",
"stage-0"
],
plugins: [],
cacheDirectory: true
}
},
{
test: /\.worker\.js$/,
loader: "worker-loader",
query: {
inline: true,
name: "[name].js"
}
},
{
test: /\.json/,
loader: "json-loader"
},
{
test: /\.html$/,
loader: 'raw'
}
],
noParse: /jquery[\-.0-9a-z]*/
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
ko: 'expose-loader?ko!knockout',
Clipboard: 'expose-loader?Clipboard!clipboard'
}),
],
resolve: {
modules: [
path.resolve(__dirname),
path.join(__dirname, 'scripts/vendors/'),
path.join(__dirname, 'node_modules/'),
path.join(__dirname, 'scripts/components/')
]
}
};
if (isProd) {
config.plugins.push(
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
compress: {
drop_console: true
},
mangle: {
except: ['$', 'exports', 'require']
}
})
);
}
module.exports = config;