mock MonacoEditor on build-html stage
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
87b8b13bef
commit
d85ee836d3
@@ -104,7 +104,7 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
const RmServiceWorkerPlugin = require('webpack-remove-serviceworker-plugin');
|
||||
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
||||
|
||||
exports.onCreateWebpackConfig = ({ rules, plugins, actions }) => {
|
||||
exports.onCreateWebpackConfig = ({ stage, rules, plugins, actions }) => {
|
||||
actions.setWebpackConfig({
|
||||
module: {
|
||||
rules: [rules.js({
|
||||
@@ -131,10 +131,26 @@ exports.onCreateWebpackConfig = ({ rules, plugins, actions }) => {
|
||||
),
|
||||
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || '')
|
||||
}),
|
||||
new RmServiceWorkerPlugin(),
|
||||
new RmServiceWorkerPlugin()
|
||||
]
|
||||
});
|
||||
if (stage !== 'build-html') {
|
||||
actions.setWebpackConfig({
|
||||
plugins: [
|
||||
new MonacoWebpackPlugin()
|
||||
]
|
||||
});
|
||||
}
|
||||
if (stage === 'build-html') {
|
||||
actions.setWebpackConfig({
|
||||
plugins: [
|
||||
plugins.normalModuleReplacement(
|
||||
/react-monaco-editor/,
|
||||
require.resolve('./src/__mocks__/monacoEditorMock.js')
|
||||
)
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.onCreateBabelConfig = ({ actions }) => {
|
||||
|
4
packages/learn/src/__mocks__/monacoEditorMock.js
Normal file
4
packages/learn/src/__mocks__/monacoEditorMock.js
Normal file
@@ -0,0 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import React from 'react';
|
||||
|
||||
export default () => React.createElement('div');
|
Reference in New Issue
Block a user