This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
104 lines (95 loc) · 2.38 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
'use strict';
var path = require('path');
var webpack = require('webpack');
var webpackPostcssTools = require('webpack-postcss-tools');
var map = webpackPostcssTools.makeVarMap('src/index.css');
var CompressionPlugin = require("compression-webpack-plugin");
const host = process.env.HOST || 'localhost';
const port = parseInt(process.env.PORT) + 1 || 3001;
const BASEURL = global.hasOwnProperty('window') ? '' : `http://${host}:${port}`;
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
main: [
`webpack-dev-server/client?${BASEURL}`,
'webpack/hot/only-dev-server',
'./src/client'
],
vendor: [
'bluebird',
'highlight.js',
'humps',
'isomorphic-fetch',
'lodash',
'methods',
'react',
'react-highlight',
'react-redux',
'react-router',
'react-style',
'redux',
'redux',
'redux-devtools',
'redux-form',
'redux-logger',
'redux-thunk',
'sass'
]
},
cssnext: {
browsers: 'last 2 versions'
},
output: {
path: path.join(__dirname, '/public/js/'),
filename: 'app.js',
publicPath: `${BASEURL}/js/`
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.CommonsChunkPlugin('vendor', 'common.js', Infinity),
new webpack.optimize.UglifyJsPlugin(),
new CompressionPlugin({
asset: "{file}.gz",
algorithm: "gzip",
regExp: /\.js$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
],
resolve: {
extensions: ['', '.js'],
packageMains: ['webpack', 'browser', 'web', 'style', 'main']
},
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
},{
test: /\.jsx$/,
loader: 'jsx'
},
{ test: /\.css$/, loader: 'style!css?importLoaders=1!postcss' },
{
test: /\.((png)|(eot)|(woff)|(ttf)|(svg)|(gif))$/,
loader: 'file?name=/[hash].[ext]'
}
]
},
postcss: [
webpackPostcssTools.prependTildesToImports,
require('postcss-custom-properties')({
variables: map.vars
}),
require('postcss-custom-media')({
extensions: map.media
}),
require('postcss-custom-selector')({
extensions: map.selector
}),
require('postcss-calc')()
]
};