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.pull/38174/head
parent
f3a386982a
commit
c76978bdfe
|
@ -161,25 +161,31 @@ exports.createPages = function createPages({ graphql, actions, reporter }) {
|
|||
|
||||
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({
|
||||
node: {
|
||||
fs: 'empty'
|
||||
},
|
||||
plugins: [
|
||||
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()
|
||||
]
|
||||
plugins: newPlugins
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue