docbrown/config/webpack/environment.js
Suzanne Aitchison e3c97d18d6
Update storybook mention autocomplete component to take over whole textarea (#13044)
* Revert "Revert "Update storybook autocomplete component (#12980)" (#13027)"

This reverts commit f393dd2bbc.

* create helper function to replace node, add comments

* minor refactors
2021-03-18 15:04:59 +00:00

57 lines
1.9 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'),
'@components': path.resolve(
__dirname,
'../../app/javascript/shared/components',
),
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
};
});
// 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 ||
'master',
}),
);
}
module.exports = environment;