This repository was archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
78 lines (67 loc) · 1.92 KB
/
webpack.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
/**
* @see http://webpack.github.io/docs/configuration.html
* for webpack configuration options
*/
var path = require('path');
var railsRoot = path.join(__dirname);
var railsAssetsDir = path.join(railsRoot, 'app', 'assets');
var railsJsDir = path.join(railsAssetsDir, 'javascripts');
var NODE_ENV =
process.env.NODE_ENV ||
process.env.RAILS_ENV ||
process.env.RACK_ENV ||
'development';
// 'context' sets the directory where webpack looks for module files you list
// in your 'require' statements
var context = railsJsDir;
// 'entry' specifies the entry point, where webpack starts reading all
// dependencies listed and bundling them into the output file.
var entry = {
main: 'main_entry_point.js',
};
// 'output' specifies the filepath for saving the bundled output
// generated by webpack.
var output = {
filename: '[name].js',
path: path.join(railsJsDir, 'bundle'),
// Serve webpack dev server assets properly
publicPath: 'http://localhost:8080/',
};
// External dependencies which are already available in the global scope
var externals = {
};
var jsxLoaders;
if (NODE_ENV === 'development') {
jsxLoaders = ['react-hot', '6to5'];
}
else {
jsxLoaders = ['6to5'];
}
// @see http://webpack.github.io/docs/using-loaders.html
var moduleLoaders = [
{ test: /\.js$/, exclude: /node_modules\//, loaders: ['6to5'] },
{ test: /\.jsx$/, exclude: /node_modules\//, loaders: jsxLoaders },
];
// Webpack module configuration
var webpModule = {
loaders: moduleLoaders
};
// Settings related to resolving require()-statement files
var resolve = {
root: railsJsDir,
// @see http://webpack.github.io/docs/configuration.html#resolve-extensions
extensions: ['', '.js', '.jsx'],
};
// Plugins for Webpack
// http://webpack.github.io/docs/using-plugins.html
var plugins = [
];
module.exports = {
context: context,
entry: entry,
output: output,
externals: externals,
module: webpModule,
resolve: resolve,
plugins: plugins,
};