This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.config.js
106 lines (100 loc) · 2.15 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
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var settings = require('../../enclave.js')
var HotReloader = new webpack.HotModuleReplacementPlugin()
var pathPrefix = '../../'
var isDeveloping
try {
isDeveloping = require('./dev-mode')
} catch (e) {
isDeveloping = ''
}
if (isDeveloping) {
pathPrefix = ''
settings = {
live: 'true',
index: './example/index.html',
entry: './example/App.js',
output: './example/dist',
port: 8080,
}
}
var liveReloadPort
var liveReloadServer
if (JSON.parse(settings.live)) {
liveReloadPort = 'webpack-dev-server/client?http://localhost:' + settings.port
liveReloadServer = 'webpack/hot/dev-server'
} else {
liveReloadPort = null
liveReloadServer = null
}
var entryArr = [
liveReloadPort,
liveReloadServer,
pathPrefix + settings.entry
].filter(function(item) {
return !!item && item
})
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: pathPrefix + settings.index,
filename: 'index.html',
inject: 'body'
})
module.exports = {
entry: entryArr,
output: {
publicPath: '/',
path: pathPrefix + settings.output,
filename: 'index_bundle.js'
},
module: {
loaders: [
{
test: /\.js[x]?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: [
'es2015',
'stage-0',
'react'
]
}
},
{
test: /\.json$/,
exclude: /node_modules/,
loader: 'json'
},
{
test: /\.(otf|eot|ttf|woff|png|jpe?g|txt)/i,
loader: 'url-loader?limit=8192'
},
{
test: /\.svg$/,
exclude: /node_modules/,
loader: 'raw-loader'
},
{
test: /\.[s]?css$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader!sass-loader'
}
]
},
plugins: [
HTMLWebpackPluginConfig,
HotReloader,
],
devtool: 'cheap-module-eval-source-map',
devServer: {
contentBase: pathPrefix + settings.output,
historyApiFallback: {
index: '/',
},
hot: true,
},
resolve: {
extensions: ['', '.js', '.jsx']
}
}