UNPKG

554 BJavaScriptView Raw
1'use strict';
2// moves the last /**/ block to the top of the output
3// assuming the source doesn't have any other /**/ blocks,
4// this will be the header
5// this is hackier than it should be, but gets the job done for now
6export default function () {
7 return {
8 renderChunk(code) {
9 const pattern = /^(\/\*[\S\s]*?\*\/)$/gm;
10 const matches = code.match(pattern);
11 if (!matches) {
12 return {
13 code: code
14 };
15 }
16 const header = matches[matches.length - 1];
17 return {
18 code: `${header}\n${code.replace(header, '')}`
19 };
20 }
21 };
22}