In my Vue 3 + Typescript app, using `npm run build` compiles the app into the `dist` folder for deployment. I have a web worker typescript file that I want to compile separately so it ends up in the root of the `dist` folder as `worker.js`. Here's what I'm trying to achieve:
dist
|- worker.js
src
|- worker.ts // Compiles to js file in dist folder
I attempted this by using webpack's `DefinePlugin` in my `vue.config.js` like this:
const webpack = require('webpack')
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
entry: `${__dirname}/src/worker.ts`,
module: {
rules: [
{
test: /worker\.ts$/,
use: 'ts-loader',
exclude: /node-modules/
}
]
},
resolve: {
extensions: ['.ts']
},
output: {
filename: 'worker.js',
path: `${__dirname}/dist`
}
})
],
resolve: {
alias: {
vue$: 'vue/dist/vue.esm-bundler.js'
}
}
}
}
However, running `npm run build` doesn't include the `worker.ts` file in the `dist` folder at all, not even as a chunk. Any suggestions on how to make this work or if it's even possible? Appreciate any help!