-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including scripts twice, when used with HTMLWebpackPlugin. #61
Comments
Usually when you get tags twice it's because of the content your html template, or because webpack was already injecting the file. Can you check that whether the duplicate file is still being added if you remove it from the |
I tried this with inject:body as commented.
Here is my complete webpack.conf. `const { CleanWebpackPlugin } = require('clean-webpack-plugin') const { root } = require('../helpers') // you can use your own root method. module.exports = { |
Can you try removing the HtmlWebpackTagsPlugin from your webpack config and verify if the script/file is still there in your generated html file? I don't think it can be this plugin that is adding files twice, or else the unit tests would have caught it (ex: https://github.com/jharris4/html-webpack-tags-plugin/blob/master/spec/end_to_end.spec.js#L183) |
I tried to remove this and the file is not getting included and when I add it again then it is getting imported twice. |
I had found something weird about this package. Findings-1 To make title and base options working, i'd updated "html-webpack-plugin": "^4.3.0", after which i need to remove html-loader from webpack to make this title and base work. The reason is when using template option in html-webpack-plugin with html-loader, title and base options are not working. So after updating the html-webpack-plugin only this multi inclusion of file problem gets generated, So i can say that this is the issue with the combination of html-webpack-plugin and html-webpack-tags-plugin. Please have a check with the combination of html-webpack-plugin and html-webpack-tags-plugin, If required please include html-loader as well. Hope this information helps you to debug the package code or find some alternative way of working. ##################################################################### Findings-2 If we start adopting Findings-1 then we have to correct the code, but if we start working with Findings-2 then we need to deprecate this package. |
This plugin IS a plugin for I can try to help you pinpoint if there's something in your webpack configuration that's causing the issue if you provide a link to a repository that reproduces the issue. |
Include scripts twice when used with HTMLWebpackPlugin and no HTML-loader.
new HtmlWebPackPlugin({
title: appTitle,
templateParameters: {
title: appTitle,
},
favicon: './src/assets/img/favicon.ico',
template: './src/index.html',
filename: './index.html',
inject: 'body',
base: process.env.BUILD_DOMAIN === 'release' ?
/${appName}/
: '/',}),
new HtmlWebpackTagsPlugin({
scripts: 'config/env.js',
}),
Versions ->
"copy-webpack-plugin": "^6.0.1",
"html-webpack-plugin": "^4.3.0",
Getting this as output
The text was updated successfully, but these errors were encountered: