-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathwebpack.config.base.mjs
executable file
·66 lines (58 loc) · 1.52 KB
/
webpack.config.base.mjs
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
/**
* Base webpack config used across other specific configs
*/
import _ from 'lodash';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import webpack from 'webpack';
import appPkg from './app/package.json' with { type: 'json' };
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const externals = _.get(appPkg, 'dependencies', {});
const additionalExternals = _.get(appPkg, 'optionalDependencies', {});
export default {
module: {
rules: [{
test: /\.jsx?$/,
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}],
exclude: /node_modules/
},
// https://github.com/ashtuchkin/iconv-lite/issues/204#issuecomment-432048618
{
test: /node_modules[\/\\](iconv-lite)[\/\\].+/,
resolve: {
aliasFields: ['main']
}
}]
},
output: {
path: path.join(__dirname, 'app'),
// https://github.com/webpack/webpack/issues/1114
library: {
type: 'commonjs2'
}
},
/**
* Determine the array of extensions that should be used to resolve modules.
*/
resolve: {
extensions: ['.js', '.jsx', '.json'],
alias: {
superagent: 'superagent/lib/client.js',
emitter: 'component-emitter',
reduce: 'reduce-component'
}
},
resolveLoader: { },
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'production'
}),
],
externals: [...Object.keys(externals || {}), ...Object.keys(additionalExternals || {})]
};