-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathwebpack.config.js
More file actions
120 lines (116 loc) · 3.73 KB
/
Copy pathwebpack.config.js
File metadata and controls
120 lines (116 loc) · 3.73 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
const path = require('path')
const globals = require('./globals')
const webpack = require('webpack')
require('dotenv').config()
let isProduction
module.exports = (env = {}) => {
isProduction = env.production === true
return {
entry: {
app: ["core-js/stable", "regenerator-runtime/runtime", 'lodash.throttle', 'lodash.debounce', 'dompurify', 'picturefill', './src/js/index.js'],
},
output: {
filename: isProduction ? '[name].[contenthash].js' : '[name].js',
chunkFilename: isProduction ? '[name].[contenthash].js' : '[name].js',
path: path.resolve(__dirname, 'dist', 'js'),
publicPath: `${globals.PP}/js/`,
clean: false // Don't clean the dist folder to preserve copied files
},
module: {
rules: [{
test: /\.m?js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
modules: 'auto',
targets: {
browsers: ['last 2 versions', '> 1%']
}
}],
],
plugins: [
'@babel/plugin-syntax-dynamic-import'
]
}
}],
}, {
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
}]
},
plugins: [
new webpack.DefinePlugin({
PP: JSON.stringify(''),
SITE_TITLE: JSON.stringify(globals.SITE_TITLE),
DESCRIPTION: JSON.stringify(globals.DESCRIPTION),
SITE_URL: JSON.stringify(globals.SITE_URL),
DEVELOPER_NAME: JSON.stringify(globals.DEVELOPER_NAME),
DEVELOPER_URL: JSON.stringify(globals.DEVELOPER_URL),
GOOGLE_ANALYTICS_ID: JSON.stringify(globals.GOOGLE_ANALYTICS_ID),
'process.env.REOWN_PROJECT_ID': JSON.stringify(process.env.REOWN_PROJECT_ID),
'process.env.ETHEREUM_NODE_URL': JSON.stringify(process.env.ETHEREUM_NODE_URL)
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser'
})
],
resolve: {
alias: {
dist: globals.Dir.dist,
src: globals.Dir.src,
css: globals.Dir.css,
js: globals.Dir.js,
utils: globals.Dir.utils,
static: globals.Dir.static,
images: globals.Dir.images,
videos: globals.Dir.images,
vendor: globals.Dir.vendor,
views: globals.Dir.views,
pages: globals.Dir.pages,
partials: globals.Dir.partials,
"process/browser": require.resolve("process/browser"),
"@vfat-io/sickle-sdk": path.resolve(__dirname, "node_modules/@vfat-io/sickle-sdk/dist/cjs/index.js"),
},
fallback: {
"buffer": require.resolve("buffer"),
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"assert": require.resolve("assert"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"os": require.resolve("os-browserify"),
"url": require.resolve("url"),
"zlib": require.resolve("browserify-zlib"),
"path": require.resolve("path-browserify"),
"process": require.resolve("process/browser"),
"fs": false,
"net": false,
"tls": false
},
extensions: ['.js', '.mjs', '.json'],
symlinks: false
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
}
}
}
},
experiments: {
topLevelAwait: true
},
devtool: isProduction ? false : 'eval-source-map',
mode: isProduction ? 'production' : 'development'
}
}