2016-12-21 02:01:56 +00:00
|
|
|
const babelRuntimePath = require.resolve('babel-runtime/package')
|
|
|
|
.replace(/[\\/]package\.json$/, '')
|
|
|
|
|
2017-02-14 01:54:01 +00:00
|
|
|
const envPlugins = {
|
|
|
|
'development': [
|
|
|
|
require.resolve('babel-plugin-transform-react-jsx-source')
|
|
|
|
],
|
|
|
|
'production': [
|
|
|
|
require.resolve('babel-plugin-transform-react-constant-elements'),
|
|
|
|
require.resolve('babel-plugin-transform-react-remove-prop-types')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
const plugins = envPlugins[process.env.NODE_ENV] || []
|
2017-02-10 19:05:13 +00:00
|
|
|
|
2016-12-21 02:01:56 +00:00
|
|
|
module.exports = {
|
|
|
|
presets: [
|
2017-02-08 12:05:25 +00:00
|
|
|
[require.resolve('babel-preset-latest'), {
|
|
|
|
'es2015': { modules: false }
|
|
|
|
}],
|
2016-12-21 02:01:56 +00:00
|
|
|
require.resolve('babel-preset-react')
|
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
require.resolve('babel-plugin-react-require'),
|
|
|
|
require.resolve('babel-plugin-transform-object-rest-spread'),
|
|
|
|
require.resolve('babel-plugin-transform-class-properties'),
|
|
|
|
require.resolve('babel-plugin-transform-runtime'),
|
|
|
|
require.resolve('styled-jsx/babel'),
|
2017-02-14 01:54:01 +00:00
|
|
|
...plugins,
|
2016-12-21 02:01:56 +00:00
|
|
|
[
|
|
|
|
require.resolve('babel-plugin-module-resolver'),
|
|
|
|
{
|
|
|
|
alias: {
|
|
|
|
'babel-runtime': babelRuntimePath,
|
|
|
|
'next/link': require.resolve('../../../lib/link'),
|
|
|
|
'next/prefetch': require.resolve('../../../lib/prefetch'),
|
|
|
|
'next/css': require.resolve('../../../lib/css'),
|
|
|
|
'next/head': require.resolve('../../../lib/head'),
|
|
|
|
'next/document': require.resolve('../../../server/document'),
|
2017-02-08 19:59:33 +00:00
|
|
|
'next/router': require.resolve('../../../lib/router'),
|
|
|
|
'next/error': require.resolve('../../../lib/error')
|
2016-12-21 02:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|