Skip to content

Instantly share code, notes, and snippets.

@jayu
Created May 2, 2020 17:35
Show Gist options
  • Save jayu/0436ca3dc920470c9d8208f22d6614f9 to your computer and use it in GitHub Desktop.
Save jayu/0436ca3dc920470c9d8208f22d6614f9 to your computer and use it in GitHub Desktop.
Linaria with Gatsby without plugins
module.exports = {
presets: [
'babel-preset-gatsby',
[
'linaria/babel',
{
evaluate: true,
displayName: process.env.NODE_ENV !== 'production'
}
],
]
};
exports.onCreateWebpackConfig = ({ actions, loaders, getConfig, stage}) => {
const config = getConfig()
config.module.rules = [
...config.module.rules.filter(
rule => String(rule.test) !== String(/\.js?$/)
),
{
...loaders.js(),
test: /\.js?$/,
options: {
babelrc: false,
configFile: false,
presets: [
['@babel/preset-env', { useBuiltIns: 'usage' }],
'@babel/preset-react'
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread'
]
},
},
{
test: /\.js?$/,
loader: 'linaria/loader',
options: {
sourceMap: stage.includes('develop'),
displayName: stage.includes('develop'),
babelOptions: {
presets: ['babel-preset-gatsby'],
},
},
exclude: /node_modules/
},
]
actions.replaceWebpackConfig(config)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment