2createStudio / postcss-sprites

Generate sprites from stylesheets.
MIT License
413 stars 50 forks source link

sprites is not a function #38

Closed canuzunoglu closed 8 years ago

canuzunoglu commented 8 years ago

Hi,

I'm having a strange error when i'm trying to use gulp with postcss-sprites (3.0.2) but when i use v2.0.3 it's working.

Here is my code;

var postcss = require('gulp-postcss');
var sprites = require('postcss-sprites');

var postcssModules = [
    sprites({ //line 40 in erros
       basePath: './src/',
       stylesheetPath: './src/scss/',
       spritePath: './assets/img/'
    })
]

gulp.task('sass', function () {
      return gulp.src('./src/scss/style.scss')
         .pipe(postcss(postcssModules))
         .pipe(gulp.dest('./assets/css'))
});

Here is my error;

sprites is not a function
at Object.<anonymous> (/Users/user/Desktop/projectname/gulpfile.js:40:5)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:181:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:174:9)
at /usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:148:9
at /usr/local/lib/node_modules/gulp/node_modules/v8flags/index.js:13:7
at nextTickCallbackWith0Args (node.js:452:9)
at process._tickCallback (node.js:381:13)
at Function.Module.runMain (module.js:431:11)
vvasilev- commented 8 years ago

You will need to use a slightly different require.

var sprites = require('postcss-sprites').default;

See Kill CommonJS default export behaviour - babel/babel#2212