-
-
Notifications
You must be signed in to change notification settings - Fork 631
/
webpack.client.base.config.js
79 lines (68 loc) · 2.08 KB
/
webpack.client.base.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
// Common client-side webpack configuration used by
// webpack.client.rails.hot.config and webpack.client.rails.build.config.
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const { resolve, join } = require('path');
const { assetLoaderRules } = require('./webpack.common.config');
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: resolve(__dirname),
entry: {
// This will contain the app entry points defined by
// webpack.client.rails.hot.config and webpack.client.rails.build.config
'app-bundle': [
'./app/startup/clientRegistration',
],
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
images: join(process.cwd(), 'app', 'assets', 'images'),
},
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
DEBUG: false,
}),
new webpack.DefinePlugin({
TRACE_TURBOLINKS: devBuild,
}),
// https://webpack.js.org/guides/code-splitting-libraries/#implicit-common-vendor-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor-bundle',
// We don't want the default vendor.js name
filename: 'vendor-bundle-[hash].js',
minChunks(module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1;
},
}),
new ManifestPlugin({
publicPath: output.publicPath,
writeToFileEmit: true
}),
],
module: {
rules: [
...assetLoaderRules,
{
test: require.resolve('jquery'),
use: [
{
loader: 'expose-loader',
options: 'jQuery'
},
{
loader: 'expose-loader',
options: '$'
},
],
},
],
},
};