forked from reinvent-fiuba/RPL-2.0-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (70 loc) · 2.19 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
const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require("path");
const Dotenv = require("dotenv-webpack");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = (env, argv) => {
// Get the root path (assuming your webpack config is in the root of your project!)
const currentPath = path.join(__dirname);
// Create the fallback path (the production .env)
const basePath = `${currentPath}/.env`;
// We're concatenating the webpack mode name to our filename to specify the correct env file!
const envPath = `${basePath}.${argv.mode}`;
return {
entry: "./src/index.js",
output: {
publicPath: "/",
path: path.resolve(__dirname, "./dist"),
filename: "index_bundle.[hash].js",
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: ["file-loader"],
},
{
test: /\.ttf$/,
use: ["file-loader"],
},
],
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html",
favicon: "./src/favicon.ico",
}),
new Dotenv({ path: envPath, systemvars: true }),
new MonacoWebpackPlugin({
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
languages: ["cpp", "javascript", "python", "java"],
}),
new BundleAnalyzerPlugin({ openAnalyzer: true, analyzerMode: "json" }),
new CompressionPlugin(), // https://medium.com/@selvaganesh93/how-to-serve-webpack-gzipped-file-in-production-using-nginx-692eadbb9f1c
],
};
};