fingerpan / vue-cli-plugin-dll

Vue CLI 3 plugin for Webpack DllPlugin/DllReferencePlugin
MIT License
76 stars 22 forks source link

我可以向你请教一个问题吗 #14

Closed Sayid1 closed 5 years ago

Sayid1 commented 5 years ago

:)

我自己配置dllplugin,运行yarn serve打开页面一直报错。但是yarn build后却可以正常打开页面

这是webpack.config.dll.js

...
const AssetsPlugin = require('assets-webpack-plugin')
module.exports = {
  entry: {
    vender: ['vue']
  },
  output: {
    path: path.join(__dirname, 'dll'),
    filename: 'dll.[name]_[hash].js',
    library: '[name]_[hash]'
  },
  plugins: [
    new webpack.DllPlugin({
      name: '[name]_[hash]',
      path: path.join(__dirname, 'dll', 'manifest.json')
    }),
    new AssetsPlugin({
      filename: 'bundle-config.json',
      path: './'
    })

这是vue.config.js

...
module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.DllReferencePlugin({
        manifest: require('./dll/manifest.json')
      }),
      new HtmlWebpackPlugin({
        inject: true,
        template: './public/index.html',
        filename: 'index.html',
        vendorJsName: bundleConfig.vender.js
      })
    ]
  }
}

public/index.html里面加了一行

<script src="dll/<%= htmlWebpackPlugin.options.vendorJsName %>"></script>
Sayid1 commented 5 years ago

yarn serve 打开页面错误如下

Uncaught SyntaxError: Unexpected token <
Uncaught ReferenceError: vender_87f3be8acd6aadd91537 is not defined
    at eval (eval at dll-reference vender_87f3be8acd6aadd91537 (app.js:2106), <anonymous>:1:18)
    at Object.dll-reference vender_87f3be8acd6aadd91537 (app.js:2106)
    at __webpack_require__ (app.js:724)
    at fn (app.js:101)
    at eval (global.js from dll-reference vender_87f3be8acd6aadd91537?478a:1)
    at Object../node_modules/webpack/buildin/global.js (app.js:1896)
    at __webpack_require__ (app.js:724)
    at fn (app.js:101)
    at eval (punycode.js:521)
    at Object../node_modules/node-libs-browser/node_modules/punycode/punycode.js (app.js:1685)
Sayid1 commented 5 years ago

:)

Sayid1 commented 5 years ago

我在github上放了一个在线链接https://github.com/Sayid1/dll-test

fingerpan commented 5 years ago

我已经在你的github地址回答你的错误问题。

wangbing0401 commented 4 years ago

问题解决了吗,我也遇见了

Sayid1 commented 4 years ago

问题解决了吗,我也遇见了

看上面的repo和issue