This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
forked from folio-org/stripes-webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cli.dev.js
79 lines (65 loc) · 2.47 KB
/
webpack.config.cli.dev.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
// Top level Webpack configuration for running a development environment
// from the command line via devServer.js
const webpack = require('webpack');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const { getModulesPaths, getStripesModulesPaths } = require('./webpack/module-paths');
const { tryResolve } = require('./webpack/module-paths');
const esbuildLoaderRule = require('./webpack/esbuild-loader-rule');
const utils = require('./webpack/utils');
const buildBaseConfig = require('./webpack.config.base');
const cli = require('./webpack.config.cli');
const useBrowserMocha = () => {
return tryResolve('mocha/mocha-es2018.js') ? 'mocha/mocha-es2018.js' : 'mocha';
};
const buildConfig = (stripesConfig) => {
const modulePaths = getModulesPaths(stripesConfig.modules);
const stripesModulePaths = getStripesModulesPaths();
const allModulePaths = [...stripesModulePaths, ...modulePaths];
const base = buildBaseConfig(allModulePaths);
const devConfig = Object.assign({}, base, cli, {
devtool: 'inline-source-map',
mode: 'development',
cache: {
type: 'filesystem',
name: 'FOLIOCache',
},
target: 'web',
infrastructureLogging: {
appendOnly: true,
level: 'warn',
},
});
// Override filename to remove the hash in development due to memory issues (STCOR-296)
devConfig.output.filename = 'bundle.js';
devConfig.entry = [
'webpack-hot-middleware/client',
...devConfig.entry.css,
'@folio/stripes-ui',
];
devConfig.plugins = devConfig.plugins.concat([
new webpack.ProvidePlugin({
process: 'process/browser.js',
// add 'Buffer' global required for tests/reporting tools.
Buffer: ['buffer', 'Buffer']
}),
]);
// include HMR plugins only when in development
if (utils.isDevelopment) {
devConfig.plugins = devConfig.plugins.concat([
new webpack.HotModuleReplacementPlugin(),
new ReactRefreshWebpackPlugin()
]);
}
// This alias avoids a console warning for react-dom patch
devConfig.resolve.alias.process = 'process/browser.js';
devConfig.resolve.alias['mocha'] = useBrowserMocha();
devConfig.module.rules.push(esbuildLoaderRule(allModulePaths));
// add resolutions for node utilities required for test suites.
devConfig.resolve.fallback = {
"crypto": require.resolve('crypto-browserify'),
"stream": require.resolve('stream-browserify'),
"util": require.resolve('util-ex'),
};
return devConfig;
}
module.exports = buildConfig;