harlan-zw / nuxt-webpack-optimisations

Make your Nuxt.js webpack builds faster ⚡
269 stars 8 forks source link

Risky profile doesnt seems to work #29

Closed Daniel4Digital closed 2 years ago

Daniel4Digital commented 3 years ago

Describe the bug Risky profile doesn't seem to work as it should, the others seems to work perfectly. If I enable hardsource and parallel directly into my nuxt config, my build time on the 2nd run is 8 sec, with this library it takes always 52sec, the same as safe and experimental.

No Optimizations dev: 1m30s ~ 40s hot reload: 1.6 ~ 2.3s

Safe dev: 51 ~ 54s hot reload: 1.8s ~ 2.2

Experimental dev: 51 ~ 52 hot reload: 1.8 ~ 1.9

Risky dev: 52 ~ 53 hot reload: 2.2 ~ 2.3

Expected behavior I was expecting it to do the hardsource and parallel, but it doesn't...

I am using vue 2, with nuxt 2.15.7, and vuetify 2.5.8.

harlan-zw commented 3 years ago

Hey @Daniel4Digital

Thanks for the issue report. I haven't come across this issue myself. The only thing that would not let you enable the risky profile is if you're using the measure mode. Parallel is not enabled if you only have 1 cpu core. Both of these show a message in the console if they are the case.

If you're still having issues can you post your nuxt.config.js or create a reproduction repo.

Cheers

Daniel4Digital commented 3 years ago
import { env } from './env'

export default {
  // Disable server-side rendering (https://go.nuxtjs.dev/ssr-mode)
  ssr: false,

  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
  },

  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
    // '~/assets/fontawesome/css/all.min.css'
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    '@/plugins/axios',
    '@/plugins/filters',
    '@/plugins/i18n',
    '@/plugins/lodash',
    '@/plugins/vee-validate',
    '@/plugins/vue-the-mask',
    '@/plugins/vue-apexchart',
    '@/plugins/vue-clipboard2',
    '@/plugins/vue-tel-input',
    '@/plugins/vue-swatches',
    '@/plugins/croppa',
    '@/plugins/credit-card-type',
    { src: '@/plugins/crisp.js', mode: 'client' },
    { src: '@/plugins/facebook.js', mode: 'client' },
    { src: '@/plugins/gtags.js', ssr: false, mode: 'client' },
  ],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: ['~/components'],

  build: {
      babel: {
      plugins: [
        ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
        ['@babel/plugin-proposal-private-methods', { loose: true }],
      ],
    },
    // cache: true,
    // hardSource: true,
    // parallel: true,
    transpile: ['vee-validate/dist/rules', 'vue-currency-input'],
  },

  buildOptimisations: {
    profile: process.env.NODE_ENV === 'development' ? 'risky ' : 'safe',
  },

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
    // https://go.nuxtjs.dev/eslint
    // '@nuxtjs/eslint-module',
    '@nuxtjs/vuetify',
    'nuxt-build-optimisations',
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/i18n',
    '@nuxtjs/proxy',
    '@nuxtjs/recaptcha',
    '@nuxtjs/style-resources',
  ],

  router: {
    base: '/admin',
    middleware: 'stateInit',
  },

  // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  axios: {
    proxy: env.isDev,
    baseURL: '/',
    withCredentials: true,
    headers: {
      common: {
        Accept: 'application/json',
        'X-REQUESTED-WITH': 'XMLHttpRequest',
      },
    },
  },

  i18n: {
    strategy: 'no_prefix',
    locales: [
      {
        name: 'Português',
        code: 'pt',
        iso: 'pt-PT',
        file: 'pt-PT.js',
      },
      {
        name: 'English',
        code: 'us',
        iso: 'en-US',
        file: 'en-US.js',
      },
    ],
    lazy: true,
    loadLanguagesAsync: true,
    langDir: 'lang/',
    defaultLocale: 'pt',
    vueI18n: {
      fallbackLocale: {
        pt: ['us'],
        en: ['pt'],
      },
      silentTranslationWarn: true,
      silentFallbackWarn: true,
    },
  },

  googleAnalytics: {
    id: env.googleAnalytics.id,
    debug: env.isDev,
  },

  publicRuntimeConfig: {
    auth: {
      register: {
        defaultPlanId: env.defaultPlanId,
      },
      providers: {
        facebook: {
          base: env.facebook.base,
          client_id: env.facebook.client_id,
          redirect_uri: env.facebook.redirect_uri,
          scope: env.facebook.scope,
        },
        google: {
          base: env.google.base,
          client_id: env.google.client_id,
          redirect_uri: env.google.redirect_uri,
          scope: env.google.scope,
        },
        microsoft: {
          base: env.microsoft.base,
          client_id: env.microsoft.client_id,
          redirect_uri: env.microsoft.redirect_uri,
          scope: env.microsoft.scope,
        },
      },
    },
    facebook: {
      pixelId: env.facebook.pixelId,
    },
    googleAnalytics: {
      id: env.googleAnalytics.id,
      debug: env.isDev,
    },
    recaptcha: {
      siteKey: env.recaptcha.siteKey,
    },
  },

  recaptcha: {
    hideBadge: false,
    version: 2,
    size: 'invisible',
  },

  vuetify: {
    customVariables: [
      '~/assets/scss/variables.scss',
      '~/assets/scss/global.scss',
    ],
    treeShake: true,
    optionsPath: '~/plugins/vuetify.options.js',
  },
}
harlan-zw commented 3 years ago

Hey @Daniel4Digital

I've looked into this a bit further with your above config and still haven't been able to replicate the issue exactly. Are you able to provide me with the logger output if any?

Also when you have these uncommented do they work?

// cache: true,
    // hardSource: true,
    // parallel: true,