該賞金過期5天。這個問題的答案有資格獲得 50聲望獎勵。 ?amo正在尋找規范的答案。
我有一個基于 Nuxt 的應用程式。Eslint 也包括在內。當我需要重建應用程式時,它會花費大約 10 分鐘。我不明白。有人告訴我我的筆記本電腦很慢。它的引數是 i5、8G 記憶體、500G SSD、Win10。我能做些什么來加速構建?
PS 是否可以禁用 EsLint 進行開發?
這是 nuxt.config.js
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: "lurity",
htmlAttrs: {
lang: "en",
},
meta: [
{ charset: "utf-8" },
{
name: "viewport",
content: "width=device-width, initial-scale=1",
},
{ hid: "description", name: "description", content: "" },
{ name: "format-detection", content: "telephone=no" },
],
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
},
server: {
port: process.env.PORT, // default: 3000
host: process.env.HOST, // default: localhost
},
modern: true,
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
"@mdi/font/css/materialdesignicons.css",
"@/assets/scss/bulma_styled.scss",
"@/assets/scss/lurity.scss",
],
router: {
middleware: "auth",
},
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
"~/plugins/helpers.js",
"~/plugins/apiCalls.js",
"~/plugins/vue-lazyload.client.js",
{ src: "~/plugins/vue-intersect.client.js", mode: "client" },
{ src: "~/plugins/gmaps.client.js", mode: "client" },
{ src: "~/plugins/google-auth.client.js", mode: "client" },
{ src: "~/plugins/google-tag-manager.client.js", mode: "client" },
{ src: "~/plugins/debounce.client.js", mode: "client" },
{ src: "~/plugins/braintree.client.js", mode: "client" },
{ src: "~/plugins/charts.client.js", mode: "client" },
{ src: "~/plugins/vuex-persist.client.js", mode: "client" },
{ src: "~plugins/leaflet.client.js", mode: "client" },
{ src: "~plugins/nuxt-client-init.client.js", mode: "client" },
"~/plugins/map-location.js",
"~/plugins/notify.js"
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/eslint
"@nuxtjs/eslint-module",
"@nuxtjs/composition-api/module",
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/buefy
"nuxt-buefy",
// https://go.nuxtjs.dev/axios
"@nuxtjs/axios",
"@nuxtjs/proxy",
[
"nuxt-i18n",
{
locales: [
{
code: "en",
iso: "en-GB",
file: "en_locale.js",
},
{
code: "sk",
iso: "sk-SK",
file: "sk_locale.js",
},
{
code: "cz",
iso: "cs-CZ",
file: "cs_locale.js",
},
],
defaultLocale: "en",
strategy: "no_prefix",
lazy: true,
vueI18n: {
silentTranslationWarn: true,
silentFallbackWarn: true,
},
langDir: "locales/",
// Enable browser language detection to automatically redirect user
// to their preferred language as they visit your app for the first time
// Set to false to disable
detectBrowserLanguage: {
// If enabled, a cookie is set once a user has been redirected to his
// preferred language to prevent subsequent redirections
// Set to false to redirect every time
useCookie: true,
// Cookie name
cookieKey: "i18n_redirected",
// Set to always redirect to value stored in the cookie, not just once
alwaysRedirect: false,
// If no locale for the browsers locale is a match, use this one as a fallback
fallbackLocale: "en",
},
},
],
],
buefy: { css: false, materialDesignIcons: false, defaultLocale: "sk-SK" },
proxy: {
// Simple proxy
"/api": {
target:
process.env.PROXY || (process.env.NODE_ENV === "production"
? "https://portal-api.lurity.com"
: "https://portaldev-api.lurity.com"),
},
},
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
proxy: true,
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
transpile: ["vuex-stores"],
loaders: {
scss: {
sourceMap: true,
implementation: require("sass"),
additionalData: `@import "~@/assets/scss/_bulma_variables.scss"; @import "~@/assets/scss/variables.scss";`,
},
},
},
};
uj5u.com熱心網友回復:
就配置而言,這里沒有什么令人震驚的 ( nuxt.config.js)。
所以我想這取決于您構建時機器上運行的內容。另外,我不確定在 Windows 中構建是否較慢,但這也可能是一個原因。
您可能會詢問朋友或將 github 鏈接分享給具有更強大硬體配置的人來診斷構建速度。
我確實在我的裝備中運行以下內容:
- 最新的 LTS ubuntu (
20.04) - 2x 32GB DDR4 4000MHz Trident Z 皇家 CAS 18
- 銳龍 R9 5950x @stock
- 2TB 三星 Pro NVME
從我的經驗來看,主要有幫助的是大量 RAM(數量) 速度以適應您的 CPU。然后,這一切都歸結為 Webpack 設定或其他構建工具相關設定 IMO。
最后,沒有精確的數字,這個問題有點難以回答。
另一件事,可能是查看實際構建并嘗試用自己的眼睛找出緩慢的地方,它會縮小您的問題 IMO。
uj5u.com熱心網友回復:
10 分鐘是一個荒謬的構建時間。不知道為什么是10分鐘。但是,如果您正在尋求一種提高 Nuxt 構建速度的方法,您可以使用 Vite!剛剛出來,提高構建速度真是太棒了。https://vite.nuxtjs.org/
uj5u.com熱心網友回復:
您可以檢查您的構建并發現更大的塊,嘗試有選擇地洗掉它們應該會引導您找到問題的根源。
試試這個命令: yarn nuxt build --analyze
它會在瀏覽器中顯示你的包,如果沒有,http://localhost:8888
更多資訊:Nuxt 分析和Webpack 包分析器
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/314079.html
