-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (77 loc) · 2.33 KB
/
webpack.config.js
File metadata and controls
91 lines (77 loc) · 2.33 KB
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
91
// For inspiration on your webpack configuration, see:
// https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client
// https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/client
/* global require module */
const webpack = require("webpack");
const { resolve } = require("path");
const ManifestPlugin = require("webpack-manifest-plugin");
const webpackConfigLoader = require("react-on-rails/webpackConfigLoader");
const configPath = resolve("..", "config");
const { devBuild, manifest, webpackOutputPath, webpackPublicOutputDir } =
webpackConfigLoader(configPath);
const Dotenv = require("dotenv-webpack");
const config = {
context: resolve(__dirname),
entry: {
"babel-bundle": [
"es5-shim/es5-shim",
"es5-shim/es5-sham",
"babel-polyfill"
],
"auth-bundle": "./app/startup/auth",
"users-profile-bundle": "./app/startup/users-profile"
},
output: {
// Name comes from the entry section.
filename: "[name]-[hash].js",
// Leading slash is necessary
publicPath: `/${webpackPublicOutputDir}`,
path: webpackOutputPath,
},
resolve: {
extensions: [".js", ".jsx"],
},
plugins: [
new Dotenv({
path: "../.env.development", // Path to .env file (this is the default)
safe: false // load .env.example (defaults to "false" which does not use dotenv-safe)
}),
new webpack.EnvironmentPlugin({
NODE_ENV: "development", // use "development" unless process.env.NODE_ENV is defined
DEBUG: false,
API_URL: null,
HOST_URL: null
}),
new ManifestPlugin({ fileName: manifest, writeToFileEmit: true })
],
module: {
rules: [
{
test: require.resolve("react"),
use: {
loader: "imports-loader",
options: {
shim: "es5-shim/es5-shim",
sham: "es5-shim/es5-sham",
},
},
},
{
test: /\.jsx?$/,
use: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.(png|jpg)$/,
loader: "url-loader?limit=25000"
}
],
},
};
module.exports = config;
if (devBuild) {
console.log("Webpack dev build for Rails"); // eslint-disable-line no-console
module.exports.devtool = "eval-source-map";
} else {
console.log("Webpack production build for Rails"); // eslint-disable-line no-console
}