fix: prevent duplication of Monaco webpack plugin (#38131)
It seems that adding it during the 'build-html' stage meant it was creating new, unminified, versions of the scripts and overwriting the existing, minified, ones.
This commit is contained in:
committed by
GitHub
parent
f3a386982a
commit
c76978bdfe
@ -161,25 +161,31 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
|||||||
|
|
||||||
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
||||||
|
|
||||||
exports.onCreateWebpackConfig = ({ plugins, actions }) => {
|
exports.onCreateWebpackConfig = ({ stage, plugins, actions }) => {
|
||||||
|
const newPlugins = [
|
||||||
|
plugins.define({
|
||||||
|
HOME_PATH: JSON.stringify(
|
||||||
|
process.env.HOME_PATH || 'http://localhost:3000'
|
||||||
|
),
|
||||||
|
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || ''),
|
||||||
|
ROLLBAR_CLIENT_ID: JSON.stringify(process.env.ROLLBAR_CLIENT_ID || ''),
|
||||||
|
ENVIRONMENT: JSON.stringify(
|
||||||
|
process.env.FREECODECAMP_NODE_ENV || 'development'
|
||||||
|
),
|
||||||
|
PAYPAL_SUPPORTERS: JSON.stringify(process.env.PAYPAL_SUPPORTERS || 404)
|
||||||
|
})
|
||||||
|
];
|
||||||
|
// The monaco editor relies on some browser only globals so should not be
|
||||||
|
// involved in SSR. Also, if the plugin is used during the 'build-html' stage
|
||||||
|
// it overwrites the minfied files with ordinary ones.
|
||||||
|
if (stage !== 'build-html') {
|
||||||
|
newPlugins.push(new MonacoWebpackPlugin());
|
||||||
|
}
|
||||||
actions.setWebpackConfig({
|
actions.setWebpackConfig({
|
||||||
node: {
|
node: {
|
||||||
fs: 'empty'
|
fs: 'empty'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: newPlugins
|
||||||
plugins.define({
|
|
||||||
HOME_PATH: JSON.stringify(
|
|
||||||
process.env.HOME_PATH || 'http://localhost:3000'
|
|
||||||
),
|
|
||||||
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || ''),
|
|
||||||
ROLLBAR_CLIENT_ID: JSON.stringify(process.env.ROLLBAR_CLIENT_ID || ''),
|
|
||||||
ENVIRONMENT: JSON.stringify(
|
|
||||||
process.env.FREECODECAMP_NODE_ENV || 'development'
|
|
||||||
),
|
|
||||||
PAYPAL_SUPPORTERS: JSON.stringify(process.env.PAYPAL_SUPPORTERS || 404)
|
|
||||||
}),
|
|
||||||
new MonacoWebpackPlugin()
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user