-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·103 lines (98 loc) · 2.68 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
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = new require("extract-text-webpack-plugin");
var OptimizeJsPlugin = require("optimize-js-plugin");
var ExtractStyles = new ExtractTextPlugin('main.css');
var host = (process.env.HOST || 'localhost');
var port = (+process.env.PORT) || 3000;
var isProduction = process.env.NODE_ENV === 'production';
module.exports = {
context: path.join(__dirname, './client'),
entry: {
jsx: './index.jsx',
//html: './index.html',
vendor: [
'react',
'react-dom',
'react-redux',
'react-router',
'react-router-redux',
'redux',
'ramda',
'i18next',
'i18next-browser-languagedetector',
'react-i18next',
'ilyabirman-likely'
]
},
output: {
path: path.join(__dirname, './static'),
filename: 'bundle.js',
//prod: publicPath: 'http://' + host + ':' + port + '/ElementsBattle/'
publicPath: 'http://' + host + ((!isProduction) ? (':' + port) : '' ) + '/' + ((isProduction) ? 'static/' : '')
},
module: {
rules: [
{
test: /\.html$/,
use: 'file-loader?name=[name].[ext]'
},
{
test: /\.css$/,
include: /client/,
use: ExtractStyles.extract([
'css-loader?modules&camelCase&sourceMap&importLoaders=1&localIdentName=[local]___[hash:base64:5]&minimize',
'postcss-loader'
]),
},
{
test: /\.css$/,
exclude: /client/,
use: ExtractStyles.extract({
use: 'css-loader'
})
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
'react-hot-loader',
'babel-loader'
]
},
{
test: /\.(png|jpg|jpeg|svg|eot|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]'
}
}
}
],
},
resolve: {
extensions: ['.js', '.jsx', '.json', '.css', '.png', '.jpg'],
modules: [
path.join(__dirname, 'client'),
'node_modules'
],
},
plugins: [
ExtractStyles,
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js'}),
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development') }
}),
new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}, output: {comments: false}}),
new OptimizeJsPlugin({
sourceMap: true
})
],
devServer: {
contentBase: './client',
hot: true
},
devtool: (process.env.NODE_ENV === 'production') ? '#source-map' : 'eval'
}