forked from Nick-1979/polkadot-Js-Plus-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.shared.cjs
105 lines (100 loc) · 2.53 KB
/
webpack.shared.cjs
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
// Copyright 2019-2023 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-extension-manifest-plugin');
const pkgJson = require('./package.json');
const manifest = require('./manifest.json');
const packages = [
'extension',
'extension-base',
'extension-chains',
'extension-dapp',
'extension-inject',
'extension-ui'
];
module.exports = (entry, alias = {}) => ({
context: __dirname,
devtool: false,
entry,
module: {
rules: [
{
test: /\.m?js/, // added for plus
resolve: {
fullySpecified: false
}
},
{
exclude: /(node_modules)/,
test: /\.(js|mjs|ts|tsx)$/,
use: [
{
loader: require.resolve('babel-loader'),
options: require('@polkadot/dev/config/babel-config-webpack.cjs')
}
]
},
{
test: [/\.svg$/, /\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.woff2?$/],
use: [
{
loader: require.resolve('url-loader'),
options: {
esModule: false,
limit: 10000,
name: 'static/[name].[ext]'
}
}
]
}
]
},
output: {
chunkFilename: '[name].js',
filename: '[name].js',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
path: path.join(__dirname, 'build')
},
performance: {
hints: false
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser.js'
}),
new webpack.IgnorePlugin({
contextRegExp: /moment$/,
resourceRegExp: /^\.\/locale$/
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new CopyPlugin({ patterns: [{ from: 'public' }] }),
new ManifestPlugin({
config: {
base: manifest,
extend: {
version: pkgJson.version.split('-')[0] // remove possible -beta.xx
}
}
})
],
resolve: {
alias: packages.reduce((alias, p) => ({
...alias,
[`@polkadot/${p}`]: path.resolve(__dirname, `../${p}/src`)
}), alias),
extensions: ['.js', '.jsx', '.ts', '.tsx'],
fallback: {
crypto: require.resolve('crypto-browserify'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify')
}
},
watch: false
});