Good day everyone! I'm trying to develop an npm package that contains a web worker inside. If I import the scripts of my "../index.js" package, everything works. But if I import my package via npm link then an error appears in the console:
files in the public directory are served at the root path. Instead of /assets/index.8a595105.js, use /index.8a595105.js.
My package vite config:
import { resolve } from 'path'
import { defineConfig } from 'vite'
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
export default defineConfig({
plugins: [
cssInjectedByJsPlugin(),
],
build: {
sourcemap: true,
lib: {
entry: resolve(__dirname, 'index.js'),
name: 'weather-condition',
fileName: (format) => `weather-condition.${format}.js`,
},
rollupOptions: {
external: ['ol'],
output: {
globals: { ol: 'ol' }
}
},
},
})
My example vite config where I use my package:
const { defineConfig } = require('vite')
module.exports = defineConfig({
build: {
sourcemap: true,
},
optimizeDeps: {
include: ['@lhs/weather_condition'],
},
publicDir: 'assets',
})
Thanks for any help!)