-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathwebpack.config.js
76 lines (75 loc) · 1.74 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
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
module.exports = (config, context) => {
return {
entry: {
app: path.resolve(__dirname, "src/app.js"),
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "demo.js",
},
devServer: {
devMiddleware: {
writeToDisk: true,
},
static: {
directory: path.join(__dirname, "./"),
},
onListening: !config.devServer ? "" : config.devServer.onListening,
open: true,
port: 8004,
hot: true,
host: "0.0.0.0",
},
// Set watch to true for dev purposes.
watch: false,
plugins: [
new CopyPlugin({
patterns: [
{
from: `${path.dirname(require.resolve(`froala-editor`))}`,
to: path.resolve(__dirname, "dist/froala-editor"),
},
],
}),
// Add the DefinePlugin to define process.env variable
new webpack.DefinePlugin({
"process.env": {
FROALA_API_KEY: JSON.stringify(process.env.FROALA_API_KEY),
},
}),
],
mode: "none",
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpg|gif)$/i,
type: "asset/inline",
},
{
// For the modal close, minimize, maximize icons
test: /\.svg$/,
type: "asset/source",
},
{
test: /\.html$/i,
exclude: /node_modules/,
loader: "html-loader",
},
],
},
stats: {
colors: true,
},
experiments: {
topLevelAwait: true,
asyncWebAssembly: true,
},
};
};