Skip to content

Commit ae5f4fb

Browse files
committed
wip: port url
1 parent 7d3c005 commit ae5f4fb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/url/src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import fs from 'fs';
55

66
import makeDir from 'make-dir';
77
import mime from 'mime';
8-
import { createFilter } from '@rollup/pluginutils';
8+
import { createHookFilter } from '@rollup/pluginutils';
99

1010
const fsStatPromise = util.promisify(fs.stat);
1111
const fsReadFilePromise = util.promisify(fs.readFile);
@@ -21,16 +21,16 @@ export default function url(options = {}) {
2121
emitFiles = true,
2222
fileName = '[hash][extname]'
2323
} = options;
24-
const filter = createFilter(include, exclude);
2524

2625
const copies = Object.create(null);
2726

2827
return {
2928
name: 'url',
30-
load(id) {
31-
if (!filter(id)) {
32-
return null;
33-
}
29+
load: {
30+
filter: {
31+
id: createHookFilter(include, exclude)
32+
},
33+
handler(id) {
3434
this.addWatchFile(id);
3535
return Promise.all([fsStatPromise(id), fsReadFilePromise(id)]).then(([stats, buffer]) => {
3636
let data;
@@ -65,6 +65,7 @@ export default function url(options = {}) {
6565
}
6666
return `export default "${data}"`;
6767
});
68+
}
6869
},
6970
generateBundle: async function write(outputOptions) {
7071
// Allow skipping saving files for server side builds.

0 commit comments

Comments
 (0)