-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (93 loc) · 2.52 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
"use strict"
const path = require("path");
const env = process.env.WEBPACK_ENV;
let config = {};
if (env === 'dev') {
config = require('./webpack.develop.config');
}
else if (env === 'prod') {
config = require('./webpack.production.config');
}
if (env) {
config.resolve = {
alias: {
app: path.resolve(__dirname, 'app'),
config: path.resolve(__dirname, 'app/config.'+env)
}
}
config.entry = {
app: ['./app/index.js']
};
if (!config.plugins) {
config.plugins = [];
}
let globalModule = {
preLoaders: [
{
test: /\.js$/, // include .js files
exclude: /(node_modules|sepcon)/, // exclude any and all files in the node_modules folder
loader: "jshint-loader"
}
],
loaders: [
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg|jpg|jpeg|png)(\?v=[a-zA-Z0-9]\.[a-zA-Z0-9]\.[a-zA-Z0-9])?$/,
loader: 'file-loader'
},
{
test: /\.js$/,
exclude: /(node_modules|vendors)/, // exclude any and all files in the node_modules folder
loader: 'babel-loader'
},
{
test: /\.html$/,
loader: 'html-loader'
}
]
};
if (config.module) {
if (config.module.loaders) {
config.module.loaders = config.module.loaders.concat(globalModule.loaders);
}
else {
config.module.loaders = globalModule.loaders;
}
if (config.module.preLoaders) {
config.module.preLoaders = config.module.preLoaders.concat(globalModule.preLoaders);
}
else {
config.module.preLoaders = globalModule.preLoaders;
}
}
else {
config.module = globalModule;
}
}
else {
config = {
entry: {
app: __dirname + '/dist/app.js'
},
output: {
path: __dirname + '/dist',
publicPath: __dirname + '/images'
}
};
}
config.devServer = {
colors: true,
hot: true,
inline: true,
progress: true,
host: 'localhost',
contentBase: env === 'dev' ? '' : path.resolve('dist'),
port: env === 'dev' ? 3005 : 3006,
historyApiFallback: {
index: '/index.html'
}
};
module.exports = config;