-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
77 lines (72 loc) · 2.24 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
import path from "path";
import webpack from "webpack";
import ExtractTextPlugin from "extract-text-webpack-plugin";
const nodeModules = path.join(process.cwd(), "node_modules");
module.exports = config => ({
entry: {
[config.bundleName]: [
process.env.PHENOMIC_ENV !== "static" &&
require.resolve("webpack-hot-middleware/client"),
process.env.PHENOMIC_ENV !== "static" &&
require.resolve("react-hot-loader/patch"),
"./App.js"
].filter(item => item)
},
output: {
publicPath: "/", // @todo make this dynamic
path: path.join(process.cwd(), "dist"),
filename: "[name].js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: require.resolve("babel-loader"),
options: {
babelrc: false,
presets: [require.resolve("@phenomic/babel-preset")],
plugins: [
require.resolve("react-hot-loader/babel")
// require.resolve("babel-plugin-styled-components")
]
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: require.resolve("style-loader"),
use: require.resolve("css-loader")
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: "styles.css",
disable: process.env.PHENOMIC_ENV !== "static"
}),
process.env.PHENOMIC_ENV !== "static" &&
new webpack.HotModuleReplacementPlugin(),
process.env.NODE_ENV === "production" &&
new webpack.optimize.UglifyJsPlugin()
].filter(item => item),
resolve: {
// react-native(-web) | react-primitives
extensions: [".web.js", ".js", ".json"],
alias: {
"react-native": "react-native-web",
// to ensure a single module is used
react: path.resolve(path.join(nodeModules, "react")),
"react-dom": path.resolve(path.join(nodeModules, "react-dom")),
"react-router": path.resolve(path.join(nodeModules, "react-router"))
}
},
// eslint-disable-next-line max-len
// https://github.com/facebookincubator/create-react-app/blob/fbdff9d722d6ce669a090138022c4d3536ae95bb/packages/react-scripts/config/webpack.config.prod.js#L279-L285
node: {
fs: "empty",
net: "empty",
tls: "empty"
}
});