我正在尝试使用webpack的dllPlugin来使我的块变小,并且我在客户端使它运行良好但在服务器端渲染中出错了.
我以此为例,使其更简单,这是我的演示代码:
webpack.config.dll.js
// webpack.config.dll.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
a: ['./a']
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
library: '[name]'
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, 'dist', 'manifest.json'),
name: '[name]'
})
]
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: './example',
output: {
path: path.join(__dirname, 'dist'),
filename: 'output.js'
},
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./dist/manifest.json')
})
] …Run Code Online (Sandbox Code Playgroud)