jantimon / html-webpack-plugin

Simplifies creation of HTML files to serve your webpack bundles
MIT License
10.71k stars 1.31k forks source link

Is there a way to set the script tag type to 'text/javascript'. #1780

Closed mohanramegowda closed 1 year ago

mohanramegowda commented 1 year ago

Prerequisites

Delete the above section and the instructions in the sections below before submitting

Description

If this is a feature request, explain why it should be added. Specific use-cases are best.

For bug reports, please provide as much relevant info as possible.

Error Message & Stack Trace

COPY THE ERROR MESSAGE, INCLUDING STACK TRACE HERE

Config

Copy the relevant section from webpack.config.js:

module.exports = {
  entry: 'app.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  module: {
    rules: [
      ...
    ]
  }
  plugins: [
    new HtmlWebpackPlugin({
      scriptLoading: 'text/javascript'
    }),
    ...
  ]
}

Copy your template file:

<!DOCTYPE html>
<html>
    <head>
        <title>My App</title>
    </head>
    <body>
    </body>
</html>

Relevant Links

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:

node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
npm --version
npm ls webpack
npm ls html-webpack-plugin
childrentime commented 1 year ago

Unfortunately, this option is not available here. But fortunately, you can customize js files by inheriting the plugin and using getHooks(compilication).alterAssetTagGroups, it's a little troublesome🥹

alexander-akait commented 1 year ago

Close in favor of https://github.com/jantimon/html-webpack-plugin/issues/1663