-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
92 lines (84 loc) · 1.8 KB
/
webpack.config.babel.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
import HtmlWebpackPlugin from 'html-webpack-plugin';
import path from 'path';
import merge from 'webpack-merge';
import validate from 'webpack-validator';
import dev from './webpack.config.dev';
import prod from './webpack.config.prod';
let paths = {
src: path.join(__dirname, '/src'),
dist: path.join(__dirname, '/dist'),
css: path.join(__dirname, '/src/css'),
images: path.join(__dirname, '/src/assets/img')
};
let defaults = {
entry: {
app: paths.src,
style: paths.css + '/style.css'
},
output: {
path: paths.dist
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
}
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
include: paths.src,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: 'file?name=/assets/img/[name].[hash].[ext]',
include: paths.images
},
{
test: /\.svg$/,
loader: 'babel?presets[]=es2015,presets[]=react!svg-react'
}
],
},
plugins: [
new HtmlWebpackPlugin({
title: 'tom hughes - js developer',
template: './src/public/index.ejs'
}),
new HtmlWebpackPlugin({
filename: '200.html',
title: 'tom hughes - js developer',
template: './src/public/index.ejs'
})
]
};
let config;
if ( process.env.npm_lifecycle_event === 'build' ) {
// prod config
config = merge(
defaults,
prod({
paths: paths
})
);
} else {
// dev config
config = merge(
defaults,
dev({
paths: paths,
server: {
host: process.env.HOST,
port: process.env.PORT
}
})
);
}
export default validate(config);