-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathwebpack.config.js
81 lines (79 loc) · 2.51 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
77
78
79
80
81
const webpack = require('webpack')
const path = require('path')
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const config = {
// devtool: 'inline-source-map',
// mode: 'development',
mode: 'production',
entry: path.resolve(__dirname, './index.js'),
output: {
path: path.resolve(__dirname, './public'),
filename: './index.js'
},
resolve: {
alias: {
'minecraft-protocol': path.resolve(
__dirname,
'node_modules/minecraft-protocol/src/index.js'
), // Hack to allow creating the client in a browser
express: false,
net: 'net-browserify',
fs: 'memfs'
},
fallback: {
zlib: require.resolve('browserify-zlib'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer/'),
events: require.resolve('events/'),
assert: require.resolve('assert/'),
crypto: require.resolve('crypto-browserify'),
path: require.resolve('path-browserify'),
constants: require.resolve('constants-browserify'),
os: require.resolve('os-browserify/browser'),
http: require.resolve('http-browserify'),
https: require.resolve('https-browserify'),
timers: require.resolve('timers-browserify'),
// fs: require.resolve("fs-memory/singleton"),
child_process: false,
perf_hooks: path.resolve(__dirname, 'perf_hooks_replacement.js'),
dns: path.resolve(__dirname, 'dns.js')
}
},
plugins: [
// fix "process is not defined" error:
new CleanWebpackPlugin(),
new webpack.ProvidePlugin({
process: 'process/browser'
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
new webpack.NormalModuleReplacementPlugin(
/prismarine-viewer[/|\\]viewer[/|\\]lib[/|\\]utils/,
'./utils.web.js'
),
new CopyPlugin({
patterns: [
{ from: 'index.html', to: './index.html' },
{ from: '../../public/blocksStates/', to: './blocksStates/' },
{ from: '../../public/textures/', to: './textures/' },
{ from: '../../public/worker.js', to: './' },
]
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new LodashModuleReplacementPlugin()
],
devServer: {
contentBase: path.resolve(__dirname, './public'),
compress: true,
inline: true,
// open: true,
hot: true,
watchOptions: {
ignored: /node_modules/
}
}
}
module.exports = config