anteriovieira / nuxt-sass-resources-loader

SASS resources (e.g. variables, mixins etc.) module for NuxtJs
https://www.npmjs.com/package/nuxt-sass-resources-loader
185 stars 15 forks source link

production ready (with now) #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi @anteriovieira,

Thank you for the plugin, really useful for me in dev mode. Unfortunately I can't get it works in production. (I'm trying to deploy the website with now)

image

Do you have a tips for me?

Cheers :)

anteriovieira commented 6 years ago

Hi @tchret , did you install the plugin in dev mode? I saw that the documentation (install) was outdated

You must install in production mode.

ghost commented 6 years ago

It works great now, thank you :)

sam-b-rose commented 6 years ago

@tchret @anteriovieira I have the plugin in my project dependencies (not devDependencies) but am still getting this error :\ Any other thoughts?

Error now-error

package.json package-json

anteriovieira commented 6 years ago

Can I see how you implemented it in the nuxt.config.js file?

sam-b-rose commented 6 years ago

Sure thing! Here is my nuxt.config.js (minus some project specific stuff)

const path = require('path');

require('dotenv').config({
  silent: true,
  path: process.env.NODE_ENV === 'production' ? '.prod.env' : '.dev.env'
});

module.exports = {
  build: {
    extractCSS: true,
    vendor: ['jwt-decode', 'axios'],
    postcss: [require('autoprefixer')()]
  },
  buildDir: 'dist/client',
  cache: true,
  css: ['@/assets/style/main.scss'],
  env: {
    HOST: process.env.HOST,
    PORT: process.env.PORT
  },
  head: {
    // project specific info
  },
  manifest: {
    // project specific info
  },
  modules: [
    '@nuxtjs/pwa',
    '@nuxtjs/component-cache',
    ['nuxt-sass-resources-loader', '@/assets/style/variables.scss']
  ],
  plugins: ['~/plugins/axios', '~/plugins/font-awesome'],
  loading: {
    color: '#2b67f5'
  },
  render: {
    static: {
      maxAge: '1y',
      setHeaders(res, path) {
        if (path.includes('sw.js')) {
          res.setHeader('Cache-Control', 'public, max-age=0');
        }
      }
    }
  },
  router: {
    middleware: ['ssr-cookie', 'https']
  },
  srcDir: path.resolve(__dirname, 'src', 'client')
};