This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
76 lines (70 loc) · 1.83 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
const path = require('path');
const fs = require('fs');
const findEslintFile = (options) => {
if (options.eslintFile) {
if (fs.existsSync(options.eslintFile)) {
console.log(`using custom eslint file at ${options.eslintFile}`);
return options.eslintFile;
}
console.warn(`custom eslint file not found at ${options.eslintFile}`);
}
const rootEslint = path.resolve('./.eslintrc');
if (fs.existsSync(rootEslint)) {
console.log(`using custom eslint file at ${rootEslint}`);
return rootEslint;
}
// default internal file
return path.join(__dirname, '.eslintrc');
};
module.exports = (options) => {
const config = {
cache: true,
mode: 'development',
resolve: {
modules: ['node_modules', path.join(__dirname, 'node_modules')],
extensions: ['.js', '.jsx', '.json']
},
entry: options.entryPoints,
output: {
path: path.join(options.outputDir),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: 'pre',
exclude: /node_modules/,
loader: require.resolve('eslint-loader'),
options: {
configFile: findEslintFile(options)
}
},
{
test: /\.(js|jsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [
[
require.resolve('@babel/preset-env'),
{
loose: true,
modules: false,
targets: '> 0.25%, not dead'
}
],
require.resolve('@babel/preset-react')
]
}
}
]
},
plugins: [],
devtool: 'cheap-source-map',
performance: {
maxAssetSize: 1500000,
maxEntrypointSize: 1500000
}
};
return config;
};