npm зависимость vue -runtime-template не работает в производственной сборке (npm запускать сборку) - PullRequest
0 голосов
/ 07 мая 2020

Я создаю расширение chrome, используя Vue CLI и vue -cli-plugin-browser-extension (https://www.npmjs.com/package/vue-cli-plugin-browser-extension).

Мне нужно используйте v-runtime-template (https://www.npmjs.com/package/v-runtime-template) для компиляции шаблонов на лету.

В режиме разработки все в порядке (npm run serve), но если я попытаюсь построить проект (npm запустить сборку) для производства, v-runtime-template не работает, похоже, что зависимость не импортируется вообще.

компонент. vue

<template>
 <div id="component">

    <v-runtime-template  :template="template"/>

  </div>

</template>

<script>
import VRuntimeTemplate from "v-runtime-template";

export default {
  name: 'component',
  props: ['props'],
  components: {
    VRuntimeTemplate
  },
  data() {
    return {
        test: 'interpolated'
        template: 'message {{test}}'
    };
  }
}
</script>

vue .config. js

module.exports = {
  pages: {
    popup: {
      template: 'public/index.html',
      entry: './src/popup/main.js',
      title: 'Popup'
    }
  },
  pluginOptions: {
    browserExtension: {
      componentOptions: {
        background: {
          entry:  'src/background.js'
        },
        contentScripts: {
          entries: {
            script: 'src/content-scripts/script.js'
          }
        }
      }
    }
  },
  runtimeCompiler: true,
}

пакет. json

{
  "name": "test",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service build --mode development --watch",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.28",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@fortawesome/vue-fontawesome": "^0.1.9",
    "bootstrap-vue": "^2.13.0",
    "core-js": "^3.6.4",
    "font-awesome": "^4.7.0",
    "get-google-fonts": "^1.2.2",
    "jquery": "^3.5.1",
    "table-to-json": "^1.0.0",
    "v-runtime-template": "^1.10.0",
    "vue": "^2.6.11",
    "vuex": "^3.1.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-vuex": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "bootstrap": "^4.4.1",
    "popper.js": "^1.16.1",
    "portal-vue": "^2.1.6",
    "sass": "^1.19.0",
    "sass-loader": "^8.0.0",
    "vue-cli-plugin-bootstrap-vue": "~0.6.0",
    "vue-cli-plugin-browser-extension": "~0.24.0",
    "vue-template-compiler": "^2.6.11"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}
...