This repository was archived by the owner on Jun 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
60 lines (57 loc) · 1.29 KB
/
webpack.config.js
File metadata and controls
60 lines (57 loc) · 1.29 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
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
module.exports = function (env) {
let prod = env.production;
let globals = {
'ENV': !prod ? '"development"' : '"production"',
'API_URL': !prod ? '"http://localhost:3333/api/"' : '"https://lightshelf-api.herokuapp.com/api/"'
};
return {
context: path.join(__dirname, 'app'),
entry: {
index: './main.js'
},
output: {
path: __dirname + '/public',
filename: 'index.js'
},
plugins: [
new webpack.DefinePlugin(globals),
new CopyWebpackPlugin([
{
from: 'index.html',
force: true
},
{
from: 'styles/*.css',
force: true
},
{
from: 'img/*',
force: true
}
])
].concat(!prod ? [] : [
new webpack.optimize.UglifyJsPlugin()
]),
devServer: {
inline: true,
port: 8080,
contentBase: "../public"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['es2015', 'react'],
plugins: ['transform-class-properties']
}
}
]
}
};
}