forked from politics-rewired/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
78 lines (75 loc) · 2.17 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
const { config } = require("./webpack/build-config");
const path = require("path");
const webpack = require("webpack");
const ManifestPlugin = require("webpack-manifest-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const basePlugins = [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(config.NODE_ENV),
"process.env.PHONE_NUMBER_COUNTRY": JSON.stringify(
config.PHONE_NUMBER_COUNTRY
)
}),
// See: https://github.com/spiritit/timezonecomplete#webpack
new webpack.ContextReplacementPlugin(
/[\/\\]node_modules[\/\\]timezonecomplete[\/\\]/,
path.resolve("tz-database-context"),
{
tzdata: "tzdata"
}
)
];
const productionPlugins = [
// Ignore publicPath as we use STATIC_BASE_URL at runtime instead
new ManifestPlugin({
fileName: config.ASSETS_MAP_FILE,
publicPath: ""
})
];
module.exports = {
context: path.resolve(__dirname, "src"),
entry: {
bundle: "./client/index.jsx"
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"]
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.css$/,
use: [{ loader: "style-loader" }, { loader: "css-loader" }]
}
]
},
plugins: basePlugins.concat(config.isProduction ? productionPlugins : []),
optimization: {
minimize: config.isProduction,
minimizer: [new TerserPlugin()]
},
devtool: config.isProduction ? "hidden-source-map" : "inline-source-map",
output: {
filename: config.isProduction ? "[name].[chunkhash].js" : "[name].js",
path: path.resolve(config.isProduction ? config.ASSETS_DIR : __dirname),
publicPath: "/assets/"
},
// See: https://webpack.js.org/configuration/dev-server/
devServer: {
contentBase: "/assets/",
publicPath: "/assets/",
hot: true,
// this should be temporary until we get the real hostname plugged in everywhere
disableHostCheck: true,
headers: { "Access-Control-Allow-Origin": "*" },
port: config.WEBPACK_PORT || config.PORT,
proxy: {
"*": `http://127.0.0.1:${config.DEV_APP_PORT}`
},
stats: "minimal"
}
};