-
-
Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathwebpack.client.base.config.js
81 lines (70 loc) · 2.19 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
80
81
// Common client-side webpack configuration used by
// webpack.client.rails.hot.config and webpack.client.rails.build.config.
const webpack = require('webpack');
const { resolve, join } = require('path');
const webpackCommon = require('./webpack.common');
const { assetLoaderRules } = webpackCommon;
const ManifestPlugin = require('webpack-manifest-plugin');
const { env, paths, publicPath } = require('./webpackConfigLoader.js');
const manifestPath = resolve('..', paths.output, paths.assets, paths.manifest);
const devBuild = process.env.NODE_ENV !== 'production';
let sharedManifest = {};
try {
sharedManifest = require(manifestPath);
} catch (ex) {
console.error(ex);
console.log('Make sure the client build (client.base.build or client.rails.build) creates a manifest in:', manifestPath);
}
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: [
'./app/startup/clientRegistration',
],
},
resolve: {
extensions: ['.js', '.jsx'],
// modules: [
// paths.source,
// paths.node_modules,
// ],
alias: {
images: join(process.cwd(), 'app', 'assets', 'images'),
},
},
resolveLoader: {
modules: [paths.node_modules],
},
plugins: [
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
new webpack.DefinePlugin({
TRACE_TURBOLINKS: devBuild,
}),
// https://webpack.js.org/guides/code-splitting-libraries/#implicit-common-vendor-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks(module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1;
},
}),
new ManifestPlugin({ fileName: paths.manifest, publicPath, writeToFileEmit: true, cache: sharedManifest }),
],
module: {
rules: [
...assetLoaderRules,
{
test: require.resolve('jquery'),
use: {
loader: 'expose-loader',
options: {
jQuery: true,
},
},
},
],
},
};