diff --git a/docs/next.config.js b/docs/next.config.js index 33caaa76fe33c8..500d8e8674d849 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -91,7 +91,7 @@ module.exports = { ...config.module, rules: config.module.rules.concat([ { - test: /\.(css|md)$/, + test: /\.md$/, loader: 'raw-loader', }, // transpile 3rd party packages with dependencies in this repository diff --git a/docs/src/modules/components/prism-okaidia.css b/docs/public/static/styles/prism-okaidia.css similarity index 100% rename from docs/src/modules/components/prism-okaidia.css rename to docs/public/static/styles/prism-okaidia.css diff --git a/docs/src/modules/components/ThemeContext.js b/docs/src/modules/components/ThemeContext.js index c238fcbafb2633..934428c7a88615 100644 --- a/docs/src/modules/components/ThemeContext.js +++ b/docs/src/modules/components/ThemeContext.js @@ -10,7 +10,7 @@ import useMediaQuery from '@material-ui/core/useMediaQuery'; import { enUS, zhCN, faIR, ruRU, ptBR, esES, frFR, deDE, jaJP } from '@material-ui/core/locale'; import { blue, pink } from '@material-ui/core/colors'; import { getCookie } from 'docs/src/modules/utils/helpers'; -import { darkTheme, setPrismTheme } from 'docs/src/modules/components/prism'; +import { loadCSS } from 'fg-loadcss/src/loadCSS'; const languageMap = { en: enUS, @@ -153,7 +153,7 @@ export function ThemeProvider(props) { const { dense, direction, paletteColors, paletteType = preferredType, spacing } = themeOptions; React.useEffect(() => { - setPrismTheme(darkTheme); + loadCSS('/static/styles/prism-okaidia.css', document.querySelector('#prismjs')); }, []); React.useEffect(() => { diff --git a/docs/src/modules/components/prism.js b/docs/src/modules/components/prism.js index 566d6f92fdafb2..bc246f81b8f9fe 100644 --- a/docs/src/modules/components/prism.js +++ b/docs/src/modules/components/prism.js @@ -1,4 +1,3 @@ -/* eslint-disable import/no-mutable-exports, global-require */ import prism from 'prismjs'; import 'prismjs/components/prism-css'; import 'prismjs/components/prism-diff'; @@ -8,18 +7,4 @@ import 'prismjs/components/prism-jsx'; import 'prismjs/components/prism-markup'; import 'prismjs/components/prism-tsx'; -let styleNode; -let darkTheme; - -if (process.browser) { - darkTheme = require('./prism-okaidia.css'); - styleNode = document.querySelector('#prismjs'); -} - -export { darkTheme }; - -export function setPrismTheme(theme) { - styleNode.textContent = theme; -} - export default prism;