我使用DLL方法打包jQuery库但是浏览器一直报错 这是我的 webpack.config.js 文件和 webpack.dll.js 文件和 index.js 文件
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'
}
import $ from 'jquery'
console.log($);
webpack打包过程没有错,文件应该是在正确的目录下生成的,参考过程没有错,只是不知道浏览器为什么老是报错,谁能帮我解决这个问题
>