-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.server.js
71 lines (66 loc) · 1.59 KB
/
webpack.config.server.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
import webpack from 'webpack'
import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin'
import nodeExternals from 'webpack-node-externals'
import _debug from 'debug'
import config from './config'
const { __PROD__ } = config.globals
const debug = _debug('server:webpack')
debug('Create configuration.')
const webpackConfig = {
target: 'node',
devtool: 'inline-source-map',
entry: './index.js',
output: {
path: config.paths.dist(),
publicPath: config.compiler_public_path,
filename: 'server.bundle.js'
},
resolve: {
modules: [config.paths.base(), 'node_modules'],
extensions: ['.js', '.jsx', '.json', '.css']
// alias: {
// 'public': config.paths.public()
// }
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
limit: 10000,
name: '[name].[ext]?[hash]'
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
externals: nodeExternals({
// do not externalize CSS files in case we need to import it from a dep
whitelist: /\.css$/
}),
plugins: [
new webpack.DefinePlugin(config.globals)
]
}
if (__PROD__) {
debug('Enable plugins for production (Dedupe & UglifyJS).')
webpackConfig.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
)
} else {
webpackConfig.plugins.push(new FriendlyErrorsPlugin())
}
module.exports = webpackConfig