docbrown/config/webpack/environment.js
Mac Siri 59ee1461a4
Upgrade to Node 20 (#20424)
* Upgrade to Node 18

* Run audit fix to resolve node 16 openssl issue

* Update babel.config.js

* Replace node-version with node-version-file

* Add NODE_OPTIONS

* Specify major version only

* Try setting locally instead

* Try custom hashFunction

* Trying two things at once

* Try without legacy option

* Add back openssl-legacy-provider

* Add resolution for terser-webpack-plugin

* Use older terser-webpack-plugin

* Revert changes to CI

* Add compression-webpack-plugin to resolution

* Use new node_module cache

* Add NODE_OPTION in build_test

* Maybe remove redundant label

* Upgrade storybook

* Update bin/webpack

* Revert "Upgrade storybook"

This reverts commit fca3fb5c8718786b7db20538c5c4ae6cf44b45b8.

* Remove unnecessary change

* Update yarn.lock again

* Now try with Node 20

* Upgrade Node module cache CI

* Lint

* Update base image sha
2023-12-15 14:27:36 +00:00

61 lines
2.1 KiB
JavaScript

/* eslint-env node */
const path = require('path');
const { environment } = require('@rails/webpacker');
const HoneybadgerSourceMapPlugin = require('@honeybadger-io/webpack');
const erb = require('./loaders/erb');
/*
The customizations below are to create the vendor chunk. The vendor chunk is no longer consumed like it was in webpacker 3.
There is no longer one vendor bundle. It gets code split based on what webpacker packs need. All the object spreading e.g. `...config.optimization` is to keep
the existing configuration and only override/add what is necessary.
The cache groups section is the default cache groups in webpack 4. See https://webpack.js.org/plugins/split-chunks-plugin/#optimizationsplitchunks.
It does not appear to be the default with webpacker 4.
*/
environment.splitChunks((config) => {
return {
...config,
resolve: {
...config.resolve,
alias: {
...(config.resolve ? config.resolve.alias : {}),
'@crayons': path.resolve(__dirname, '../../app/javascript/crayons'),
'@utilities': path.resolve(__dirname, '../../app/javascript/utilities'),
'@images': path.resolve(__dirname, '../../app/assets/images'),
'@admin': path.resolve(__dirname, '../../app/javascript/admin'),
'@components': path.resolve(
__dirname,
'../../app/javascript/shared/components',
),
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
};
});
environment.config.output.hashFunction = 'sha256';
// We don't want babel-loader running on the node_modules folder.
environment.loaders.delete('nodeModules');
environment.loaders.append('erb', erb);
if (process.env.HONEYBADGER_API_KEY && process.env.ASSETS_URL) {
environment.plugins.append(
'HoneybadgerSourceMap',
new HoneybadgerSourceMapPlugin({
apiKey: process.env.HONEYBADGER_API_KEY,
assetsUrl: process.env.ASSETS_URL,
silent: false,
ignoreErrors: false,
revision:
process.env.RELEASE_FOOTPRINT ||
process.env.HEROKU_SLUG_COMMIT ||
'main',
}),
);
}
module.exports = environment;