企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
webpack.config.js ``` const { resolve } = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: './src/js/index.js', output: { filename: 'js/built.js', path: resolve(__dirname, 'build') }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html' }) ], mode: 'production', externals: { // 拒绝jQuery被打包进来 jquery: 'jQuery' } }; ``` src/index.html ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>webpack</title> </head> <body> <h1 id="title">hello html</h1> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> </body> </html> ``` src/js/index.js ``` import $ from 'jquery'; console.log($); ```