Last active
February 27, 2020 07:23
-
-
Save ScreamZ/31bdb5c275749a1b9e75b4ae29395e49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import here to bypass non-SSR issues with EUI | |
@import "~@elastic/eui/src/theme_light.scss"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// …Some others imports before | |
const withSass = require("@zeit/next-sass"); | |
const nextConfig = { | |
webpack(config, { isServer }) { | |
// Allows to prevent crashes on server with EUi | |
if (isServer) { | |
config.externals = config.externals.map(fn => { | |
return (context, request, callback) => { | |
if (request.indexOf("@elastic/eui") > -1 || request.indexOf("react-ace") > -1) { | |
return callback(); | |
} | |
return fn(context, request, callback); | |
}; | |
}); | |
// Mock react-ace server-side | |
config.module.rules.push({ | |
test: /react-ace/, | |
use: "null-loader", | |
}); | |
// Mock HTMLElement and window server-side | |
let definePluginId = config.plugins.findIndex(p => p.constructor.name === "DefinePlugin"); | |
config.plugins[definePluginId].definitions = { | |
...config.plugins[definePluginId].definitions, | |
HTMLElement: function() {}, | |
window: function() {}, | |
}; | |
} | |
return config; | |
} | |
module.exports = withSass(nextConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment