Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run build "PurgeCSS is not enabled because you are in dev mode" #52

Closed
poldixd opened this issue Jan 9, 2020 · 2 comments
Closed

Comments

@poldixd
Copy link

poldixd commented Jan 9, 2020

I created a nuxt app with npx create-nuxt-app <project-name>. I choosed tailwind as the css framework. Here is my default nuxt.config.js


export default {
  mode: 'universal',
  /*
  ** Headers of the page
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [
    // Doc: https://github.com/nuxt-community/nuxt-tailwindcss
    '@nuxtjs/tailwindcss',
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
  ],
  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
  },
  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend (config, ctx) {
    }
  }
}

If I used npm run build the console output shows PurgeCSS is not enabled because you are in dev mode.

Next I added cross-env to the project and added the cross-env command to the package.json:

  "scripts": {
    "dev": "nuxt",
    "build": "cross-env NODE_ENV=production nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },

If I run npm run build the console shows the same output PurgeCSS is not enabled because you are in dev mode.

> cross-env NODE_ENV=production nuxt build

i Production build                                                                                                                                                          13:23:20  
start Loading module                                                                                                                                          nuxt-purgecss 13:23:20  
i PurgeCSS is not enabled because you are in dev mode                                                                                                         nuxt-purgecss 13:23:20  
√ Builder initialized                                                                                                                                                       13:23:20  
√ Nuxt files generated   

Same issue, when I added this to nuxt.config.js:

    purgeCSS: {
        enabled: true
    }
@samuraisam
Copy link

samuraisam commented Jan 14, 2020

I similarly have this issue, it appears to have been broken in this commit: 9fe24f7 where now purgeCSS can only be enabled in any env if purgeCSSinDev is true. This is easily reproducible with the latest versions of each nuxt and @nuxtjs/tailwindcss.

For now the workaround appears to be adding

tailwindcss: {
    purgeCSSInDev: process.env.NODE_ENV === 'production',
  }

to your nuxt.config.js file

@atinux
Copy link
Collaborator

atinux commented Jan 15, 2020

Really sorry about this, it's now fixed in v1.3.1

@atinux atinux closed this as completed Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants