1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Resolve styled-jsx/style when transpiling ES2015 modules. (#953)

This commit is contained in:
Arunoda Susiripala 2017-02-02 11:26:21 +05:30 committed by Tim Neutkens
parent f9717347a4
commit 24edfbdea7
2 changed files with 16 additions and 2 deletions

View file

@ -26,8 +26,7 @@ module.exports = {
'next/css': require.resolve('../../../lib/css'),
'next/head': require.resolve('../../../lib/head'),
'next/document': require.resolve('../../../server/document'),
'next/router': require.resolve('../../../lib/router'),
'styled-jsx/style': require.resolve('styled-jsx/style')
'next/router': require.resolve('../../../lib/router')
}
}
]

View file

@ -158,6 +158,21 @@ export default async function createCompiler (dir, { dev = false, quiet = false
const transpiled = babelCore.transform(content, {
presets: [require.resolve('babel-preset-es2015')],
sourceMaps: dev ? 'both' : false,
// Here we need to resolve styled-jsx/style to the absolute paths.
// Earlier we did it with the babel-preset.
// But since we don't transpile ES2015 in the preset this is not resolving.
// That's why we need to do it here.
// See more: https://github.com/zeit/next.js/issues/951
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
'styled-jsx/style': require.resolve('styled-jsx/style')
}
}
]
],
inputSourceMap: sourceMap
})