I'm using the DLL method to package the jQuery library but the browser keeps getting an error Here is my webpack.config.js file and webpack.dll.js fil

Uncaught ReferenceError: jquery is not defined at Object.766 (external “jquery.js”:1)

submited by
Style Pass
2021-05-19 04:14:49

I'm using the DLL method to package the jQuery library but the browser keeps getting an error Here is my webpack.config.js file and webpack.dll.js file and index.js file

const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const webpack = require('webpack'); const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin') module.exports = { entry: './src/js/index.js', output: { filename: 'js/bundle.js', path: path.resolve(__dirname, 'dist'), clean:true }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', scriptLoading: 'blocking' }), new webpack.DllReferencePlugin({ manifest:path.resolve(__dirname,'dll/manifest.json') }), new AddAssetHtmlWebpackPlugin({ filepath: path.resolve(__dirname, 'dll/jquery.js'), publicPath: './', }) ], mode: 'production', devtool:'source-map' };

const { resolve } = require('path'); const webpack = require('webpack'); module.exports = { entry: { jquery:['jquery'] }, output: { filename: '[name].js', path: resolve(__dirname, 'dll'), library: '[name]_[hash]', }, plugins: [ new webpack.DllPlugin({ name: '[name].js', path: resolve(__dirname, 'dll/manifest.json') }) ], mode:'production' }

Leave a Comment