-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.config.js
138 lines (133 loc) · 3.72 KB
/
webpack.dev.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
const path = require('path');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
var os = require('os');
var ifaces = os.networkInterfaces();
let ip;
Object.keys(ifaces).forEach(function(ifname) {
var alias = 0;
ifaces[ifname].forEach(function(iface) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return;
}
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
ip = iface.address;
console.log('Your local address' + ':' + alias, ip + ':8080');
} else {
// this interface has only one ipv4 adress
ip = iface.address;
console.log('Your local address', ip + ':8080');
}
++alias;
});
});
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js',
chunkFilename: '[id].js',
publicPath: '/',
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
Actions: path.resolve(__dirname, `src/stores/actions/`),
Common: path.resolve(__dirname, `src/common/`),
agileRequest: path.resolve(__dirname, `src/agileRequest/`),
},
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(s*)css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader', // translates CSS into CommonJS
// options: {
// importLoaders: 1,
// modules: true,
// localIdentName: "[name]_[local]_[hash:base64:5]"
// }
},
{ loader: 'sass-loader' },
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [
autoprefixer({
browsers: ['> 1%', 'last 2 versions'],
}),
],
},
},
],
}),
},
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [
{
loader: 'file-loader?limit=8000&name=images/[name].[ext]',
},
],
},
],
},
devServer: {
stats: 'errors-only',
historyApiFallback: true,
// host: ip,
port: 8080,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: __dirname + '/index.html',
filename: 'index.html',
inject: 'body',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
children: true,
async: true,
minChunks: Infinity,
}),
new ExtractTextPlugin({ filename: 'style.bundle.css' }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
new SWPrecacheWebpackPlugin({
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
console.log(message);
},
minify: true,
navigateFallback: __dirname + '/index.html',
navigateFallbackWhitelist: [/^(?!\/__).*/],
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
}),
],
};