flecks/packages/web/build/web-vendor.webpack.config.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-11-30 21:41:42 -06:00
const {join} = require('path');
2024-01-22 09:16:07 -06:00
const {defaultConfig, webpack} = require('@flecks/build/server');
2024-01-16 00:28:20 -06:00
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
2023-11-30 21:41:42 -06:00
const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
module.exports = async (env, argv, flecks) => {
const config = defaultConfig(flecks, {
output: {
clean: false,
path: join(FLECKS_CORE_ROOT, 'node_modules', '.cache', '@flecks', 'web', 'vendor'),
library: 'flecks_web_vendor',
filename: 'web-vendor.js',
},
plugins: [
// `config.clean` wipes out the manifest...
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
],
resolve: {
fallback: {
2024-01-16 00:28:20 -06:00
assert: require.resolve('assert'),
2023-11-30 21:41:42 -06:00
child_process: false,
fs: false,
2024-01-16 00:28:20 -06:00
path: require.resolve('path-browserify'),
process: require.resolve('process/browser'),
2023-11-30 21:41:42 -06:00
stream: false,
2024-01-16 00:28:20 -06:00
util: require.resolve('util'),
2023-11-30 21:41:42 -06:00
},
},
stats: {
warningsFilter: [
/Failed to parse source map/,
],
2024-01-16 00:28:20 -06:00
...flecks.get('@flecks/web.stats'),
2023-11-30 21:41:42 -06:00
},
});
2024-01-16 00:28:20 -06:00
const dll = flecks.get('@flecks/web.dll');
2023-11-30 21:41:42 -06:00
if (dll.length > 0) {
// Build the library and manifest.
config.entry.index = dll;
config.plugins.push(
new webpack.DllPlugin({
path: join(config.output.path, 'manifest.json'),
name: 'flecks_web_vendor',
}),
);
}
return config;
};