-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.offchain.config.js
93 lines (82 loc) · 2.1 KB
/
webpack.offchain.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"use strict";
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = (env, argv) => ({
mode: argv.mode === 'development' ? 'development' : 'production',
experiments: {
asyncWebAssembly: false,
layers: false,
lazyCompilation: false,
syncWebAssembly: true,
topLevelAwait: true,
},
devtool: argv.mode === 'development' ? "eval-source-map" : false,
stats: { errorDetails: true },
devServer: {
port: 4008,
},
// we can add more entrypoints as needed
entry: "./index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: 'index.js'
},
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
type: "asset",
},
{
test: /\.plutus$/i,
type: "asset/source",
},
],
},
resolve: {
modules: [process.env.NODE_PATH],
extensions: [".js"],
fallback: {
buffer: require.resolve("buffer/"),
http: false,
url: false,
stream: false,
crypto: false,
https: false,
net: false,
tls: false,
zlib: false,
os: false,
path: false,
fs: false,
readline: false,
child_process: false,
},
alias: {
// You should update this path to the location of your compiled scripts,
// relative to `webpack.config.js`
Scripts: path.resolve(__dirname, "scripts"),
},
},
plugins: [
new webpack.DefinePlugin({
BROWSER_RUNTIME: !!process.env.BROWSER_RUNTIME,
}),
new NodePolyfillPlugin(),
new webpack.LoaderOptionsPlugin({
debug: true,
}),
argv.mode === 'development' && new HtmlWebpackPlugin({
title: "ctl-scaffold",
template: "./index.html",
inject: 'body',
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.ContextReplacementPlugin(/cardano-serialization-lib-browser/),
new webpack.ContextReplacementPlugin(/cardano-serialization-lib-nodejs/),
].filter(Boolean),
});