-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Clear and concise description of the problem
Clear and concise description of the problem
I'm using Vite.js to build a webcomponent library for a customer.
lib: {
entry: path.resolve(__dirname, 'src/webcomponents.js'),
formats: ['es'],
name: 'webcomponents',
},This does perfectly create the desired output:
vite v2.4.4 building for production...
✓ 32 modules transformed.
dist/webcomponents.es.js 36.46kb / brotli: 10.31kb
dist/webcomponents.es.js.map 101.33kb
dist/style.css 117.61kb / brotli: 82.97kb
In the same project, we also build the application that uses this library, which basically comprises of web components as well, which serve as views. So I need a second entry point:
lib: [{
entry: path.resolve(__dirname, 'src/webcomponents.js'),
formats: ['es'],
name: 'webcomponents',
},
{
entry: path.resolve(__dirname, 'src/views.js'),
formats: ['es'],
name: 'views',
}],Unfortunately, that results in an error:
vite v2.4.4 building for production...
error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
...
Suggested solution
Instead of a single entry point for libarary mode, allow an array of entry points.
Alternative
I've tried working around this limitation by using rollupOptions instead, but wasn"t able to figure it out:
rollupOptions: [
{
input: path.resolve(__dirname, 'src/webcomponents.js'),
output: {
file: path.resolve(__dirname, 'dist/webcomponents.js'),
format: 'es'
},
}, {
input: path.resolve(__dirname, 'src/views.js'),
output: {
file: path.resolve(__dirname, 'dist/views.js'),
format: 'es'
}
}
],Unfortunately, this does not create the files I expect:
dist/index.html 3.03kb
dist/assets/index.1a413bf8.css 6.54kb / brotli: 1.96kb
dist/assets/vendor.ef70301d.js 11.19kb / brotli: 3.72kb
dist/assets/vendor.ef70301d.js.map 45.39kb
dist/assets/index.fa2e2112.js 31.74kb / brotli: 7.88kb
dist/assets/index.fa2e2112.js.map 73.46kb
Additional context
I've read and upvoted #1736 and wanted to turn this into a feature request.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Reactions are currently unavailable