nuxt-modules / style-resources

Style Resources for Nuxt 3
MIT License
589 stars 22 forks source link

FATAL Nuxt Build Error #37

Open chiboreache opened 5 years ago

chiboreache commented 5 years ago

Wildcard import — causing error Dot import — simple not working

  # Nuxt.js modules
  modules:
    [
      '@nuxtjs/style-resources'
      './modules/coffeescript'
    ]

  styleResources:
    stylus:
      [
        '~assets/*.styl' 
         or './assets/*.styl'

        '~assets/mixins.styl'
        '~assets/card-base.styl'
      ]

npx nuxt build → Version: webpack 4.29.6


ERROR in ./components/GHCard.vue?vue&type=style&index=0&id=0e928d29&lang=stylus&scoped=true& (./node_modules/css-loader/dist/cjs.js??ref--10-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--10-oneOf-1-2!./node_modules/stylus-loader??ref--10-oneOf-1-3!./node_modules/vue-loader/lib??vue-loader-options!./components/GHCard.vue?vue&type=style&index=0&id=0e928d29&lang=stylus&scoped=true&)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: Cannot read property 'type' of undefined

and so on


"dependencies": {
    "@nuxtjs/style-resources": "^0.1.2",
    "axios": "^0.18.0",
    "coffee-loader": "^0.8.0",
    "coffeescript": "^2.0.1",
    "nuxt": "*",
    "pug": "^2.0.3",
    "pug-plain-loader": "^1.0.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2"
  }
chiboreache commented 5 years ago

I also tried nuxt-stylus-resources-loader

resolve = require('path').resolve
['nuxt-stylus-resources-loader', resolve(__dirname, 'assets/**/*.styl')]

with almost the same result, error message now is a little bit more verbose

at WebpackBundler.webpackCompile (node_modules/@nuxt/webpack/dist/webpack.js:5262:15)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
manniL commented 5 years ago

@chiboreache Hey :wave:

Please provide a reproduction repo.

Dynamic asset imports should work like shown in https://github.com/nuxt-community/style-resources-module/blob/master/test/fixture/sass/nuxt.config.js#L11 (pre-processor-independent)

chiboreache commented 5 years ago

@manniL hello again :hand:

Nice link, but I'm using stylus ;)

so example file says

styleResources: {
    stylus: ['~assets/variables.styl']
  },

I can't provide anything, I just have mixins and styl file with classes, which are I want to reuse by importing in pages via `@import '~assets/someClasses' or globally, as I mentioned above

Global import not work, meanwhile simple importing works in dev and causing an error during the building time

Just right after the message: additional chunk assets processing (91%)

manniL commented 5 years ago

Try @/assets as prefix.

I can't provide anything, I just have mixins and styl file with classes, which are I want to reuse by importing in pages via `@import '~assets/someClasses' or globally, as I mentioned above

Then you can reproduce it by putting them in a codesandbox so I can play around with the project ;)

chiboreache commented 5 years ago

Just loaded my mega neat setup into CS, and apparently @import does not provide any errors... Maybe something with my local webpack, but I'll investigate that tomorrow, I'm going to sleep, finally :crescent_moon:

furthermore, I realised some undocumented logic

css: ['~assets/onlyForStyling.styl'],

styleResources: {
    stylus: ['~assets/everythingElse.styl'] or even
    stylus: ['~assets/*.styl'] but not without css object
  },

So it works, sort of but not like that css: ['~assets/styl.styl', '~assets/mixins.styl'], or that css: ['~assets/*.styl'],

So yeah, have fun heh

https://codesandbox.io/s/o7rppmxmny?fontsize=14&module=%2Fnuxt.config.js index — /assets — config

chiboreache commented 5 years ago

So, I'm back Here is working example (vuex store stop working for some reason, but whatever)

My conclusion:

css:

styleResources:


but I am still get an error for my project 😔


Ironically problem was in just an one string of styl file — transform: rotate3D(0)

what a shame...

but yeah, it would be awesome if compiler in dev mode told me about that earlier >< some one will update the docs `^^` dry docs is always causing some stupid issues..