I created a project typescript project with the Vue Cli.
I want to have a separated commands.html file that should contain the javascript code from a commands.ts file.
I put the commands.html file in the public folder, so it is copied to the dist folder when building the project.
The commands.ts file is in the root folder (in the same folder in that the public, src, node_modules, etc folders are).
Webpack should do the following:
- Minify the
commands.htmlfile (like it is minifying theindex.html) - Compile the
commands.tsfile to JavaScript - Put the generated JavaScript file to the
dist/jsfolder - Put a script tag in the
commands.htmlfile that points to the generated JavaScript file
I tried the following:
I installed html-webpack-plugin
I created a vue.config.js file with the following code:
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
configureWebpack: {
entry: {
commands: './commands.ts',
},
plugins: [
new HtmlWebpackPlugin({
filename: 'commands.html',
template: './public/commands.html',
chunks: ['commands'],
minify: {
collapseWhitespace: true,
},
}),
],
},
};
That is doing everything correctly, but it also creates a script tag in the index.html file that points to the generated JavaScript file. I think the default Webpack config of Vue is compiling the commands.ts in the bundle that is injected in the index.html file. How can I stop it from doing that?