小编sim*_*han的帖子

如何在服务器端渲染中使用webpack dll插件

我正在尝试使用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)

reactjs webpack dllplugin

5
推荐指数
0
解决办法
1166
查看次数

标签 统计

dllplugin ×1

reactjs ×1

webpack ×1