Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为生产构建时缺少Vuetify CSS_Css_Vue.js_Build_Vuetify.js - Fatal编程技术网

为生产构建时缺少Vuetify CSS

为生产构建时缺少Vuetify CSS,css,vue.js,build,vuetify.js,Css,Vue.js,Build,Vuetify.js,我们从某人那里购买了一个用Vue编写的web应用程序,我们正在开发以更改/改进它。我们添加的一件事是Vuetify,这样我们就可以使用Vuetify元素,并且在开发模式下一切都运行得很好,但是当我们为生产构建时,Vuetify元素的CSS就丢失了 我已经在网上搜索过了,并且已经尝试过了每个人的建议,但没有任何运气 任何人都知道什么是错误的,为什么npm运行的构建会缺少一些CSS 奇怪的是,Vue元素的所有UI功能都工作得很好,只是缺少CSS 请参阅下面的代码示例 main.js: import

我们从某人那里购买了一个用Vue编写的web应用程序,我们正在开发以更改/改进它。我们添加的一件事是Vuetify,这样我们就可以使用Vuetify元素,并且在开发模式下一切都运行得很好,但是当我们为生产构建时,Vuetify元素的CSS就丢失了

我已经在网上搜索过了,并且已经尝试过了每个人的建议,但没有任何运气

任何人都知道什么是错误的,为什么npm运行的构建会缺少一些CSS

奇怪的是,Vue元素的所有UI功能都工作得很好,只是缺少CSS

请参阅下面的代码示例

main.js:

import '@fortawesome/fontawesome-free/css/all.css'
import Vue from "vue";
import App from "./App.vue";
import VueMoment from "vue-moment";
import VueAnalytics from "vue-analytics";
import VueMeta from "vue-meta";
import { library } from "@fortawesome/fontawesome-svg-core";
import {
  faCoffee,
  faPlusCircle,
  faChartLine,
  faChevronDown,
  faMobile,
  faEnvelope,
  faClock,
  faUsers,
  faPaperPlane,
  faCheckCircle,
  faCheck,
  faLeaf,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import axios from "axios";
import router from "./router";
import store from "./store";
import vuetify from './plugins/vuetify';
import Vuetify from 'vuetify/lib'

library.add([
  faCoffee,
  faPlusCircle,
  faChartLine,
  faChevronDown,
  faMobile,
  faEnvelope,
  faClock,
  faUsers,
  faPaperPlane,
  faCheckCircle,
  faCheck,
  faLeaf,
]);

Vue.use(VueAnalytics, {
  id: "xxx",
  router,
});
Vue.use(VueMoment);
Vue.use(VueMeta);
Vue.component("font-awesome-icon", FontAwesomeIcon);

Vue.use(Vuetify)

axios.interceptors.response.use(undefined, async function (error) {
  if (error.response.status === 401) {
    await store.dispatch("auth/logout");
    router.push("/login");
  }
  return Promise.reject(error);
});

// Plugins
// ...

// Sass file
require("./assets/styles/main.css");

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  vuetify,
  render: (h) => h(App)
}).$mount("#app");
App.vue:

<template>
  <v-app>

    <v-main>
      <router-view/>
    </v-main>
  </v-app>
</template>

<style>
  .text-white {
      color: #fff !important;
  }

  .text-gray-600 {
    color: #757575 !important;
  }

  .font-semibold, .text-gray-700 {
    color: #616161 !important;
  }
</style>

有点难理解在哪里遗漏了什么。如果您认为这是刚刚丢失,那么请尝试添加css到HTML文件从cdn和检查工作

<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">

如果没有nuxt config和package.json中的代码,或者没有代码库的示例,这样人们就不可能排除故障。谢谢您的建议。我没有使用nuxt。添加了main.js、App.vue和package.json.Anees、dude.中的代码。。你是个救生员!CDN解决方案非常适合我。非常感谢你!现在一切看起来都很好,没有CSS丢失。我感谢你的帮助。
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
--webpack.config.js--
const path = require("path");

const VuetifyLoaderPlugin = require("vuetify-loader/lib/plugin");
const { VueLoaderPlugin } = require("vue-loader");

module.exports = {
watch: true,
entry: {
 main: 'main.js'
},
module: {
    rules: [
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.vue$/,
        use: "vue-loader",
      },
      {
        test: /\.s(c|a)ss$/,
        use: [
          "vue-style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            // Requires sass-loader@^8.0.0
            // options: {
            //   implementation: require('sass'),
            //   sassOptions: {
            //     fiber: require('fibers'),
            //     indentedSyntax: true // optional
            //   },
            // },
          },
        ],
      },
    ],
  },
  plugins: [
    new VueLoaderPlugin(),
    new VuetifyLoaderPlugin({
      /**
       * This function will be called for every tag used in each vue component
       * It should return an array, the first element will be inserted into the
       * components array, the second should be a corresponding import
       *
       * originalTag - the tag as it was originally used in the template
       * kebabTag    - the tag normalised to kebab-case
       * camelTag    - the tag normalised to PascalCase
       * path        - a relative path to the current .vue file
       * component   - a parsed representation of the current component
       */
      match(originalTag, { kebabTag, camelTag, path, component }) {
        if (kebabTag.startsWith("core-")) {
          return [
            camelTag,
            `import ${camelTag} from '@/components/core/${camelTag.substring(
              4
            )}.vue'`,
          ];
        }
      },
    }),
  ],
}