vue-cli-plugin-dll icon indicating copy to clipboard operation
vue-cli-plugin-dll copied to clipboard

Plugin must respect the 'target': 'node' for SSR setup of vue-cli and 'externals'

Open Arsync opened this issue 5 years ago • 1 comments

Example config of SSR setup: vue-cli-ssr-example and vue-cli3-ssr-project.

There is important things:

configureWebpack: () => ({
  target: TARGET_NODE ? 'node' : 'web',
  node: TARGET_NODE ? undefined : false,
  entry: {
    [target]: [`./src/entry-${target}`]
  },
  output: {
    libraryTarget: TARGET_NODE
      ? 'commonjs2'
      : undefined
  }
  // ...
}

And dll-plugin must not extract (or do it somehow else) vendors when running in server-side mode - there is one solid file as the server-entry result: 'vue-ssr-server-bundle.json'. No 'dll_library' variable. Maybe it can work as 'webpack-node-externals' - packages (except the whitelist of forced-transpilation, respect the externals property of webpack config) on the server-side must be taken directly from node_modules folder. It's all there.

Stack trace:

NodeInvocationException: dll_library is not defined
ReferenceError: dll_library is not defined
at eval (eval at dll-reference dll_library (server.js:748:1), <anonymous>:1:18)
at Object.dll-reference dll_library (server.js:748:1)
at __webpack_require__ (server.js:27:30)
at eval (webpack-internal:///./node_modules/vuetify/lib/index.js:1:19)
at Object../node_modules/vuetify/lib/index.js (server.js:319:1)
at __webpack_require__ (server.js:27:30)
at eval (webpack-internal:///./src/plugins/vuetify.js:4:69)
at Module../src/plugins/vuetify.js (server.js:497:1)
at __webpack_require__ (server.js:27:30)
at eval (webpack-internal:///./src/app.js:11:74)

Temporary solution is to set open: !TARGET_NODE && IS_DEVELOPMENT to disable plugin on server side.

Arsync avatar May 23 '19 10:05 Arsync

Yes, you are right. I will solve this problem. Thank you for your guidance.

fingerpan avatar Aug 10 '19 08:08 fingerpan