-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.server.js
87 lines (74 loc) · 2.26 KB
/
webpack.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require('dotenv').config()
const path = require('path')
const Webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const postcssConfig = require('./postcss.config')
const nodeModulesPath = path.resolve(__dirname, 'node_modules')
const sourcePath = path.resolve(__dirname, 'src')
const config = {
target: 'node',
externals: [nodeExternals({
importType: 'commonjs',
modulesDir: nodeModulesPath,
modulesFromFile: false,
whitelist: [/\.scss$/, /\.css$/, /react-toolbox/],
})],
entry: path.resolve(__dirname, 'src/server/server.js'),
output: {
path: path.resolve(__dirname, 'server'),
filename: 'index.js',
publicPath: '/',
},
resolve: {
extensions: ['', '.js', '.jsx', '.css', '.scss'],
},
module: {
loaders: [
{
test: /\.js$/,
include: [sourcePath, /react-toolbox/],
loader: 'babel-loader',
query: {
cacheDirectory: false,
presets: ['es2015', 'es2016', 'stage-2', 'react'],
plugins: [
'babel-plugin-transform-object-rest-spread',
'babel-plugin-transform-class-properties',
'transform-class-properties',
['css-modules-transform', {
extensions: ['.css', '.scss'],
generateScopedName: '[name]__[local]___[hash:base64:5]',
}],
],
},
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss',
},
{
test: /\.scss$/,
include: /react-toolbox/,
loader: 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass',
},
],
},
plugins: [
new Webpack.DefinePlugin({ 'process.env': {
NODE_ENV: JSON.stringify('production'),
PORT: JSON.stringify(process.env.PORT),
} }),
new Webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compressor: { screw_ie8: true, keep_fnames: true, warnings: false },
mangle: { screw_ie8: true, keep_fnames: true },
}),
],
postcss: () => postcssConfig,
sassLoader: {
data: '@import "shared/styles/main.qscss";',
includePaths: [sourcePath],
},
}
module.exports = config