1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-08-06 05:17:31 +02:00

build 3.5.1

This commit is contained in:
Kushagra Gour
2018-10-25 21:27:56 +05:30
parent deb507e950
commit 9b2fd7e000
7 changed files with 31 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
importScripts('./prettier/standalone.js');
function prettify({ content, type }) {
let plugins, parser;
if (type === 'js') {
parser = 'babylon';
importScripts('./prettier/parser-babylon.js');
} else if (type === 'css') {
parser = 'css';
importScripts('./prettier/parser-postcss.js');
}
if (!parser) {
return content;
}
const formattedContent = prettier.format(content, {
parser,
plugins: self.prettierPlugins
});
return formattedContent || content;
}
onmessage = e => {
postMessage(prettify(e.data));
};