box.jsx
import React from 'react';
export default class Box extends React.Component {
render() {
return <p> this a box</p>;
}
}
main.js
import React from 'react';
import Box from './box.jsx';
main();
function main() {
React.render(<Box />, document.getElementById('app'));
}
babel --presets es2015,react --plugins transform-react-jsx main.js
这样只是转换了 main.js
...
var _hello = require('./hello.jsx');
...
hello.jsx 还是没变 有没有参数可以实现全部转换?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
babel 可以接受一个目录参数,转换目录中的所有文件到另一个指定的目录