Merge pull request #2628 from clarkdo/babel_jsx

feat: transpile .jsx files
This commit is contained in:
Sébastien Chopin 2018-01-18 13:57:17 +01:00 committed by GitHub
commit c8f6dfb958
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -63,7 +63,7 @@ module.exports = function webpackBaseConfig({ name, isServer }) {
options: vueLoader.call(this, { isServer })
},
{
test: /\.js$/,
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: this.getBabelOptions({ isServer })

View File

@ -306,6 +306,11 @@ test('/jsx', async t => {
t.true(html.includes('<h1>JSX Page</h1>'))
})
test('/jsx-link', async t => {
const { html } = await nuxt.renderRoute('/jsx-link')
t.true(html.includes('<h1>JSX Link Page</h1>'))
})
test('/js-link', async t => {
const { html } = await nuxt.renderRoute('/js-link')
t.true(html.includes('<h1>vue file is first-class</h1>'))

5
test/fixtures/basic/pages/jsx-link.js vendored Normal file
View File

@ -0,0 +1,5 @@
import renderLink from './jsx-link.jsx'
export default {
render: renderLink
}

View File

@ -0,0 +1,5 @@
export default function (h) {
return (<div class='container'>
<h1>JSX Link Page</h1>
</div>)
}