forked from OpenStackweb/summit-admin
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.common.js
More file actions
150 lines (148 loc) · 4.09 KB
/
webpack.common.js
File metadata and controls
150 lines (148 loc) · 4.09 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require("webpack");
const Dotenv = require("dotenv-webpack");
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
// load env file so sentry plugin could be feed...
// eslint-disable-next-line
const env = require("dotenv").config({
path: ".env"
});
module.exports = {
entry: "./src/index.js",
plugins: [
new Dotenv({
expand: true
}),
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser"
}),
new CleanWebpackPlugin(),
// new webpack.DefinePlugin(),
new HtmlWebpackPlugin({
title: "Show Admin",
template: "./src/index.ejs"
}),
...("SENTRY_AUTH_TOKEN" in process.env &&
"SENTRY_PROJECT" in process.env &&
"SENTRY_ORG" in process.env
? [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
// Specify the directory containing build artifacts
include: [
{
paths: ["dist"],
urlPrefix: "~/"
},
{
paths: ["node_modules/openstack-uicore-foundation/lib"],
urlPrefix: "~/node_modules/openstack-uicore-foundation/lib"
}
],
// and needs the `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,
// Optionally uncomment the line below to override automatic release name detection
release: process.env.SENTRY_RELEASE
})
]
: [])
],
resolve: {
extensions: [".js", ".jsx"],
mainFields: ["browser", "module", "main"],
fallback: {
path: require.resolve("path-browserify"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
buffer: require.resolve("buffer"),
fs: require.resolve("fs"),
process: require.resolve("process"),
vm: false
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-react",
"@babel/preset-flow"
],
plugins: [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-nullish-coalescing-operator"
]
}
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
},
{
test: /\.less/,
exclude: /\.module\.less/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
},
{
test: /\.module.less/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader",
options: {
sourceMap: true,
modules: true
}
},
{
loader: "less-loader"
}
]
},
{
test: /\.scss/,
exclude: /\.module\.scss/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource"
},
{
test: /\.jpg|\.png|\.gif$/,
use: "file-loader?name=images/[name].[ext]"
},
{
test: /\.svg/,
use: "file-loader?name=svg/[name].[ext]!svgo-loader"
},
{
test: /\.ya?ml$/,
use: "js-yaml-loader"
},
// word around for react dnd
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
]
},
devtool: "source-map"
};