Skip to content

Instantly share code, notes, and snippets.

@xthezealot
Created April 21, 2020 14:43
Show Gist options
  • Save xthezealot/434c6ac5d8b637ec02821687ae3782fd to your computer and use it in GitHub Desktop.
Save xthezealot/434c6ac5d8b637ec02821687ae3782fd to your computer and use it in GitHub Desktop.
React configurations
// Gatsby + Ant Design + Less
// gatsby-config.js plugins
{
resolve: `gatsby-plugin-less`,
options: {
javascriptEnabled: true,
modifyVars: {
hack: `true; @import "${__dirname}/src/components/antd.less";`,
},
},
},
// .babelrc
{
"presets": [["babel-preset-gatsby"]],
"plugins": [
[
"import",
{ "libraryName": "antd", "libraryDirectory": "es", "style": true }
]
]
}
// src/components/antd.less
@font-size-base: 16px;
// React + UIkit
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
const Layout = ({ children }) => {
useEffect(() => {
;(async (x) => {
const UIkit = (await import('uikit/dist/js/uikit.js')).default
const Icons = (await import('uikit/dist/js/uikit-icons.js')).default
UIkit.use(Icons)
})()
})
return (
<>
<main>{children}</main>
</>
)
}
Layout.propTypes = {
children: PropTypes.node.isRequired,
}
export default Layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment