forked from OpenStackweb/call-for-presentations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
157 lines (155 loc) · 5.21 KB
/
Copy pathwebpack.common.js
File metadata and controls
157 lines (155 loc) · 5.21 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
151
152
153
154
155
156
157
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack');
const {sentryWebpackPlugin} = require("@sentry/webpack-plugin");
// load env file so sentry plugin could be feed...
const env = require("dotenv").config({
path: `.env`,
});
module.exports = {
entry: "./src/index.js",
plugins: [
// 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 HtmlWebpackPlugin({
title: 'Call for presentations',
template: './src/index.ejs'
}),
new Dotenv({
expand: true
}),
...("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: {
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: false,
process: require.resolve("process"),
}
},
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: []
}
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
},
{
test: /\.less/,
exclude: /\.module\.less/,
use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
},
{
test: /\.scss/,
exclude: /\.module\.scss/,
use: [MiniCssExtractPlugin.loader, "css-loader", { loader: 'sass-loader', options: { api: 'modern' } }]
},
{
test: /\.module.less/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
sourceMap: true,
modules: true,
}
},
{ loader: "less-loader" },
]
},
{
test: /\.module.scss/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
sourceMap: true,
modules: true,
}
},
{ loader: 'sass-loader', options: { api: 'modern' } }
]
},
{
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: /\.yaml$/,
use: 'js-yaml-loader',
},
// word around for react dnd
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
]
},
};