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:
25
app/lib/prettier-worker.js
Normal file
25
app/lib/prettier-worker.js
Normal 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));
|
||||
};
|
Reference in New Issue
Block a user