Why does popup.html need to reference the Webpack configuration of these JS files?
P粉727531237
P粉727531237 2023-09-05 17:15:09
0
1
357

I only want to reference popup.js in popup.html. However, content.js and background.js are also referenced in popup.html. Why does this happen and how do I fix it?

const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const CopyPlugin = require('copy-webpack-plugin') module.exports = { entry: { popup: './src/popup.tsx', content: './src/content.tsx', background: './src/background.ts', }, output: { filename: '[name].js', path: path.resolve(__dirname, 'dist') }, module: { rules: [{ test: /\.ts(x)?$/, use: 'ts-loader', exclude: /node_modules/ }] }, plugins: [ new HtmlWebpackPlugin({ template: './src/popup.html', filename: 'popup.html' }), new CopyPlugin({ patterns: [ { from: "public" } ] }) ] } 
      Document    

Why is this happening and how to fix it?

P粉727531237
P粉727531237

reply all (1)
P粉724737511

Well, it’s easy:

plugins: [ new HtmlWebpackPlugin({ chunks: ['content'] }) ]
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!