mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
9319c158a5
Fixes #4691 Fixes #4614 This PR gives path to https://github.com/zeit/next-plugins/pull/242 I did not add or remove `^` near dependency versions in package.json files. However, I don't exclude that some changes can be made given that rc is more stable than beta.
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
// Resolve styled-jsx plugins
|
|
function styledJsxOptions (opts) {
|
|
if (!opts) {
|
|
return {}
|
|
}
|
|
|
|
if (!Array.isArray(opts.plugins)) {
|
|
return opts
|
|
}
|
|
|
|
opts.plugins = opts.plugins.map(plugin => {
|
|
if (Array.isArray(plugin)) {
|
|
const [name, options] = plugin
|
|
return [
|
|
require.resolve(name),
|
|
options
|
|
]
|
|
}
|
|
|
|
return require.resolve(plugin)
|
|
})
|
|
|
|
return opts
|
|
}
|
|
|
|
module.exports = (context, opts = {}) => ({
|
|
presets: [
|
|
[require('@babel/preset-env'), {
|
|
modules: false,
|
|
...opts['preset-env']
|
|
}],
|
|
require('@babel/preset-react')
|
|
],
|
|
plugins: [
|
|
require('babel-plugin-react-require'),
|
|
require('@babel/plugin-syntax-dynamic-import'),
|
|
require('./plugins/react-loadable-plugin'),
|
|
[require('@babel/plugin-proposal-class-properties'), opts['class-properties'] || {}],
|
|
require('@babel/plugin-proposal-object-rest-spread'),
|
|
[require('@babel/plugin-transform-runtime'), opts['transform-runtime'] || {
|
|
helpers: false,
|
|
regenerator: true
|
|
}],
|
|
[require('styled-jsx/babel'), styledJsxOptions(opts['styled-jsx'])],
|
|
process.env.NODE_ENV === 'production' && require('babel-plugin-transform-react-remove-prop-types')
|
|
].filter(Boolean)
|
|
})
|