]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow(sfc-playground): copy server-renderer browser build
authorEvan You <yyx990803@gmail.com>
Wed, 25 May 2022 04:57:28 +0000 (12:57 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 25 May 2022 04:57:28 +0000 (12:57 +0800)
packages/sfc-playground/vite.config.ts

index 4184c791817587c0e08a35751c34f7b4e06fc997..44d5a53509f721c858f4ba70032e819d49033959 100644 (file)
@@ -21,21 +21,24 @@ function copyVuePlugin(): Plugin {
   return {
     name: 'copy-vue',
     generateBundle() {
-      const filePath = path.resolve(
-        __dirname,
-        '../vue/dist/vue.runtime.esm-browser.js'
-      )
-      if (!fs.existsSync(filePath)) {
-        throw new Error(
-          `vue.runtime.esm-browser.js not built. ` +
-            `Run "nr build vue -f esm-browser" first.`
-        )
+      const copyFile = (file: string) => {
+        const filePath = path.resolve(__dirname, file)
+        const basename = path.basename(file)
+        if (!fs.existsSync(filePath)) {
+          throw new Error(
+            `${basename} not built. ` +
+              `Run "nr build vue -f esm-browser" first.`
+          )
+        }
+        this.emitFile({
+          type: 'asset',
+          fileName: basename,
+          source: fs.readFileSync(filePath, 'utf-8')
+        })
       }
-      this.emitFile({
-        type: 'asset',
-        fileName: 'vue.runtime.esm-browser.js',
-        source: fs.readFileSync(filePath, 'utf-8')
-      })
+
+      copyFile(`../vue/dist/vue.runtime.esm-browser.js`)
+      copyFile(`../server-renderer/dist/server-renderer.esm-browser.js`)
     }
   }
 }