haifeng2013/rollup-plugin-bundle-html

Rollup output dir should be taken into account (minor and can workaround)

JohnnyFun opened this issue · 1 comments

Looks like if I use Rollup.output.dir, it fails.

For example:

output: {
    dir: 'public',
    entryFileNames: 'scripts/app.[hash].js',
    chunkFileNames: 'scripts/chunks/[name]-[hash].js'
}

Here's the stack trace:

[!] (plugin html) Error: ENOENT: no such file or directory, scandir 'scripts'
Error: ENOENT: no such file or directory, scandir 'scripts'
    at Object.readdirSync (fs.js:790:3)
    at traverse (c:\dev\ClinicianNexus\CN.Web\Svelte\node_modules\rollup-plugin-bundle-html\dist\index.cjs.js:105:19)
    at Object.writeBundle (c:\dev\ClinicianNexus\CN.Web\Svelte\node_modules\rollup-plugin-bundle-html\dist\index.cjs.js:156:4)
    at Promise.resolve.then (c:\dev\ClinicianNexus\CN.Web\Svelte\node_modules\rollup\dist\rollup.js:12064:25)

I can workaround this by just setting dir to '.' and then providing the relative path it works, so no rush on fixing:

output: {
    dir: '.',
    entryFileNames: 'public/scripts/app.[hash].js',
    chunkFileNames: 'public/scripts/chunks/[name]-[hash].js'
}

Thanks for writing this, btw! I tried several similar rollup plugins that either broken or didn't include css links.

Actually, pretty sure this is all that's wrong:

https://github.com/haifeng2013/rollup-plugin-bundle-html/blob/master/src/index.js should be using path.dirname rather than destPath.slice(0, destPath.indexOf(pathSeperator)); when dest is not provided.