mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui build
This commit is contained in:
1 parent
9c45527522
commit
7dc31d02fa
15 files changed
+10521
-3
No files matched your search
@@ -0,0 +1,32 @@
|
||||
/* eslint-disable */
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
import PluginError from 'plugin-error';
|
||||
import through from 'through2';
|
||||
import path from 'path';
|
||||
|
||||
export default function generateLocales() {
|
||||
function bufferContents(file, encoding, callback) {
|
||||
if (file.isNull()) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
if (file.isStream()) {
|
||||
this.emit('error', new PluginError('gulpGenerateLocales', 'Stream not supported'));
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
const doc = yaml.safeLoad(file.contents);
|
||||
file.contents = Buffer.from(`window.LOCALES = ${JSON.stringify(doc, null, 2)}`);
|
||||
file.path = path.join(
|
||||
path.dirname(file.path),
|
||||
`${path.basename(file.path, path.extname(file.path))}.js`
|
||||
);
|
||||
|
||||
this.push(file);
|
||||
callback();
|
||||
}
|
||||
|
||||
return through.obj(bufferContents);
|
||||
}
|
||||
Reference in new issue
Block a user