我想转换一个文件并将其放在另一个目录中,作为开发和生产构建过程的一部分。我怎样才能做到这一点?
我认为通读所有这些会有所帮助:http://www.oligriffiths.com/broccolijs/
这是一个关于西兰花如何工作的教程,以及它如何转换文件树。
对于您的特定情况,此页面将感兴趣:http://www.oligriffiths.com/broccolijs/05-es6-transpilation.html
具体来说,这个:
const funnel = require('broccoli-funnel');
const merge = require('broccoli-merge-trees');
const compileSass = require('broccoli-sass-source-maps')(require('sass'));
const babel = require('broccoli-babel-transpiler');
const appRoot = 'app';
// Copy HTML file from app root to destination
const html = funnel(appRoot, {
files: ["index.html"],
annotation: "Index file",
});
// Copy JS file into assets
let js = funnel(appRoot, {
files: ["app.js"],
destDir: "/assets",
annotation: "JS files",
});
// Transpile JS files to ES5
js = babel(js, {
browserPolyfill: true,
sourceMap: 'inline',
});
// Copy CSS file into assets
const css = compileSass(
[appRoot],
'styles/app.scss',
'assets/app.css',
{
sourceMap: true,
sourceMapContents: true,
annotation: "Sass files"
}
);
// Copy public files into destination
const public = funnel('public', {
annotation: "Public files",
});
module.exports = merge([html, js, css, public], {annotation: "Final output"});
希望这有帮助/为您提供足够的信息来实现您的需求