Permalink
Browse files

fix: should transform jsx to js (#11)

  • Loading branch information...
popomore committed Apr 1, 2018
1 parent eedc2a0 commit 9d7fdac51c6799db63d948b37e94ad47a280a7c4
@@ -62,7 +62,7 @@ class Assets {
}

setEntry(entry) {
this.entry = entry;
this.entry = entry.replace(/\.jsx?$/, '.js');
this.entryCss = entry.replace(/\.jsx?$/, '.css');
}

@@ -34,6 +34,14 @@ describe('test/assets.test.js', () => {
.expect(/<script>window.__webpack_public_path__ = '\/';<\/script>/)
.expect(200);
});

it('should GET jsx', () => {
return app.httpRequest()
.get('/account')
.expect(/<link rel="stylesheet" href="http:\/\/127.0.0.1:8000\/account.css"><\/link>/)
.expect(/<script src="http:\/\/127.0.0.1:8000\/account.js"><\/script>/)
.expect(200);
});
});

describe('production', () => {
@@ -9,6 +9,10 @@ class HomeController extends Controller {
});
}

async account() {
await this.ctx.render('account.jsx');
}

async renderString() {
await this.ctx.renderString('', {}, {
viewEngine: 'assets',
@@ -4,5 +4,6 @@ module.exports = app => {
const { router, controller } = app;

router.get('/', controller.home.index);
router.get('/account', controller.home.account);
router.get('/renderString', controller.home.renderString);
};
@@ -6,6 +6,7 @@ exports.keys = '123456';
exports.view = {
mapping: {
'.js': 'assets',
'.jsx': 'assets',
},
};
exports.assets = {

0 comments on commit 9d7fdac

Please sign in to comment.