borodean / postcss-assets

An asset manager for PostCSS
MIT License
537 stars 32 forks source link

Using pkg.name in basePath / loadPaths #69

Closed stevygee closed 7 years ago

stevygee commented 7 years ago

I often use <%= pkg.name %> in my Gruntfile to refer to the project directory in paths.

I just came across a situation where I wanted to do the same in postcss-assets' options. Specifically, I have a config variable slug set in my package.json and want to use it like this:

    postcss: {
      options: {
          map: false,
          processors: [
              require('postcss-assets')({
                basePath: 'build/<%= pkg.config.slug %>',
                loadPaths: ['images/'],
                relative: true,
                cachebuster: false
              })
          ]
      },
      style: {
          src: 'build/<%= pkg.config.slug %>/style.css'
      }
    },

With this I get a file not found or unreadable error. It works fine when I hardcode the directory name in basePath.

borodean commented 7 years ago

https://github.com/borodean/postcss-assets/issues/66