diff --git a/server/build/webpack.js b/server/build/webpack.js index a7f9bb625a0d2..b6e252a5ea350 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -10,7 +10,7 @@ import DynamicEntryPlugin from './plugins/dynamic-entry-plugin' export default async function createCompiler (dir, { hotReload = false } = {}) { dir = resolve(dir) - const pages = await glob('pages/**/*.js', { cwd: dir }) + const pages = await glob('pages/**/*.+(js|jsx)', { cwd: dir }) const entry = {} const defaultEntries = hotReload ? ['webpack/hot/dev-server'] : [] @@ -57,7 +57,7 @@ export default async function createCompiler (dir, { hotReload = false } = {}) { .replace(/[\\\/]package\.json$/, '') const loaders = [{ - test: /\.js$/, + test: /\.jsx?$/, loader: 'emit-file-loader', include: [dir, nextPagesDir], exclude (str) { @@ -68,12 +68,12 @@ export default async function createCompiler (dir, { hotReload = false } = {}) { } }] .concat(hotReload ? [{ - test: /\.js$/, + test: /\.jsx?$/, loader: 'hot-self-accept-loader', include: join(dir, 'pages') }] : []) .concat([{ - test: /\.js$/, + test: /\.jsx?$/, loader: 'babel', include: [dir, nextPagesDir], exclude (str) { diff --git a/server/resolve.js b/server/resolve.js index ca778dfd018ee..a94335501ed0a 100644 --- a/server/resolve.js +++ b/server/resolve.js @@ -25,12 +25,14 @@ export function resolveFromList (id, files) { function getPaths (id) { const i = sep === '/' ? id : id.replace(/\//g, sep) - if (i.slice(-3) === '.js') return [i] - if (i[i.length - 1] === sep) return [i + 'index.js'] + if (i.slice(-3) === '.js' || i.slice(-4) === '.jsx') return [i] + if (i[i.length - 1] === sep) return [i + 'index.js', i + 'index.jsx'] return [ i + '.js', - join(i, 'index.js') + i + '.jsx', + join(i, 'index.js'), + join(i, 'index.jsx') ] } diff --git a/test/fixtures/basic/pages/jsxpage.jsx b/test/fixtures/basic/pages/jsxpage.jsx new file mode 100644 index 0000000000000..7420ff6dfd46f --- /dev/null +++ b/test/fixtures/basic/pages/jsxpage.jsx @@ -0,0 +1,5 @@ +import React from 'react' + +export default function () { + return
Diego Milito
')) }) +test(async t => { + const html = await render('/jsxpage') + t.true(html.includes('