我想转换文件并将其放置在另一个目录中,作为开发和生产过程的一部分。我该如何实现?
答案 0 :(得分:1)
我认为通读所有这些内容会有所帮助: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"});
希望这有助于/为您提供足够的信息来满足您的需求