mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
8a5250985f
Without this, modules built with Babel or Webpack would have hard-coded absolute paths all the way back to the root of the filesystem. This prevented compilation and running on different machines or even from different directories on the same machine. With this change, paths are hard-coded to the top-most node_madules directory found, which should make them portable relative to the app. Fixes #1160
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
const relativeResolve = require('../root-module-relative-path').default(require)
|
|
|
|
const envPlugins = {
|
|
'development': [
|
|
require.resolve('babel-plugin-transform-react-jsx-source')
|
|
],
|
|
'production': [
|
|
require.resolve('babel-plugin-transform-react-remove-prop-types')
|
|
]
|
|
}
|
|
|
|
const plugins = envPlugins[process.env.NODE_ENV] || []
|
|
|
|
module.exports = {
|
|
presets: [
|
|
[require.resolve('babel-preset-latest'), {
|
|
'es2015': { modules: false }
|
|
}],
|
|
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'),
|
|
...plugins,
|
|
[
|
|
require.resolve('babel-plugin-module-resolver'),
|
|
{
|
|
alias: {
|
|
'babel-runtime': relativeResolve('babel-runtime/package'),
|
|
'next/link': relativeResolve('../../../lib/link'),
|
|
'next/prefetch': relativeResolve('../../../lib/prefetch'),
|
|
'next/css': relativeResolve('../../../lib/css'),
|
|
'next/head': relativeResolve('../../../lib/head'),
|
|
'next/document': relativeResolve('../../../server/document'),
|
|
'next/router': relativeResolve('../../../lib/router'),
|
|
'next/error': relativeResolve('../../../lib/error')
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|