sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.76k stars 151 forks source link

prependData doesn't work on postcss? and also test is wrong? #515

Closed felixsanz closed 2 years ago

felixsanz commented 2 years ago

Describe the bug

I'm trying to debug why when i pass prependData it does not work

My config is this:

...
    preprocess: [
          mdsvex(mdsvexConfig),
          preprocess({
        postcss: {
            prependData: '/* potato */',
            plugins: [
            nesting,
            customMedia,
            autoprefixer,
            ],
             },
          }),
    ],
...

Logs

To Reproduce

Expected behavior Have the css comment in the app

Stacktraces

Information about your project:

Additional context

DanielRios549 commented 2 years ago

Did you figure out how to fix this? I need to prepend a file with function selectors in order to use them with @extend, but it does not work

felixsanz commented 2 years ago

Did you figure out how to fix this? I need to prepend a file with function selectors in order to use them with @extend, but it does not work

this works:

sveltePreprocess({
  postcss: {
    prependData: `@import "${path.join(path.resolve('./src/lib/styles'), 'breakpoints.css')}";`,
    plugins: [
        cssImport,
        nesting,
        customMedia,
        autoprefixer,
    ],
},
}),

my issue was.. that i wasn't using cssImport plugin and you need it to use @import

DanielRios549 commented 2 years ago

This is weird. Need the Import plugin it's ok, but why it is necessary to use path? In config.preprocess.scss.prependData it works without resolving the path. But anyway, thanks so much, this fixes the problem.

felixsanz commented 2 years ago

This is weird. Need the Import plugin it's ok, but why it is necessary to use path? In config.preprocess.scss.prependData it works without resolving the path. But anyway, thanks so much, this fixes the problem.

it's not, i use it because i want

DanielRios549 commented 2 years ago

Strange, when I do not use path it fails to find the file

felixsanz commented 2 years ago

Strange, when I do not use path it fails to find the file

Probably because you're using a wrong path, but using fs.path you always find the right file