forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.server.rails.build.config.js
90 lines (84 loc) · 2.33 KB
/
webpack.server.rails.build.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
/* eslint comma-dangle: ["error",
{"functions": "never", "arrays": "only-multiline", "objects": "only-multiline"} ],
global-require: 0,
import/no-dynamic-require: 0,
no-console: 0 */
// Common webpack configuration for server bundle
const { resolve } = require('path');
const webpack = require('webpack');
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
const configPath = resolve('..', 'config');
const { output } = webpackConfigLoader(configPath);
const devBuild = process.env.NODE_ENV !== 'production';
module.exports = {
// the project dir
context: __dirname,
entry: [
'babel-polyfill',
'./app/bundles/comments/startup/serverRegistration',
],
output: {
// Important to NOT use a hash if the server webpack config runs separately from the client one.
// Otherwise, both would be writing to the same manifest.json file.
// Additionally, there's no particular need to have a fingerprint (hash) on the server bundle,
// since it's not cached by the browsers.
filename: 'server-bundle.js',
publicPath: output.publicPath,
path: output.path,
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
libs: resolve(__dirname, 'app', 'libs'),
},
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
DEBUG: false,
TRACE_TURBOLINKS: devBuild,
}),
],
module: {
rules: [
{
test: /\.jsx?$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: {
loader: 'css-loader/locals',
options: {
modules: true,
importLoaders: 0,
localIdentName: '[name]__[local]__[hash:base64:5]'
}
}
},
{
test: /\.scss$/,
use: [
{
loader: 'css-loader/locals',
options: {
modules: true,
importLoaders: 2,
localIdentName: '[name]__[local]__[hash:base64:5]',
}
},
{
loader: 'sass-loader'
},
{
loader: 'sass-resources-loader',
options: {
resources: './app/assets/styles/app-variables.scss',
},
}
],
},
],
},
};