2023-11-30 21:41:42 -06:00
|
|
|
const {join} = require('path');
|
|
|
|
|
|
|
|
const {defaultConfig, require: R, webpack} = require('@flecks/core/server');
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
|
|
|
|
|
|
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: {
|
2023-12-01 19:56:51 -06:00
|
|
|
assert: R.resolve('assert'),
|
2023-11-30 21:41:42 -06:00
|
|
|
child_process: false,
|
|
|
|
fs: false,
|
|
|
|
path: R.resolve('path-browserify'),
|
|
|
|
process: R.resolve('process/browser'),
|
|
|
|
stream: false,
|
2023-12-01 19:56:51 -06:00
|
|
|
util: R.resolve('util'),
|
2023-11-30 21:41:42 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
stats: {
|
|
|
|
warningsFilter: [
|
|
|
|
/Failed to parse source map/,
|
|
|
|
],
|
|
|
|
...flecks.get('@flecks/web/server.stats'),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const dll = flecks.get('@flecks/web/server.dll');
|
|
|
|
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;
|
|
|
|
};
|