1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-17 12:01:13 +02:00
Files
php-web-maker/app/lib/prettier-worker.js
Kushagra Gour 9b2fd7e000 build 3.5.1
2018-10-25 21:27:56 +05:30

26 lines
530 B
JavaScript

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));
};