Anton Medvedev
Anton Medvedev

Reputation: 3668

Error trying to compile bootstrap with gulp-less

Got this error trying to compile bootstrap with gulp-less:

 ./node_modules/.bin/gulp
[11:36:31] Using gulpfile ~/Desktop/elfet.github.io/gulpfile.js
[11:36:31] Starting 'default'...
[11:36:31] Finished 'default' after 21 ms

/Users/anton/Desktop/elfet.github.io/node_modules/gulp-less/node_modules/accord/node_modules/when/lib/decorators/unhandledRejection.js:80
        throw e;
              ^
SyntaxError: Unexpected token u in file undefined line no. undefined
    at Object.parse (native)
    at /Users/anton/Desktop/elfet.github.io/node_modules/gulp-less/node_modules/accord/lib/adapters/less.js:48:32

What to do? Here my gulpfile:

gulp.task('default', function () {
    gulp.src('src/less/*.less')
        .pipe(sourcemaps.init())
        .pipe(less({
            paths: [path.join(__dirname, 'less', 'includes')]
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('css'));

});

Upvotes: 0

Views: 1250

Answers (1)

Bass Jobsen
Bass Jobsen

Reputation: 49044

You posted the same question here https://github.com/less/less.js/issues/2452. You showed a modified bootstrap.less file, i don't think you will need these modifications.

you should create a file src/less/project.less which contains the following code:

@import "../../bower_components/bootstrap/less/bootstrap.less";

After running bower install bootstrap the above can be used with:

var gulp = require('gulp'),
    less = require('gulp-less');

gulp.task('default', function () {
    gulp.src('src/less/*.less')
        .pipe(less())
        .pipe(gulp.dest('css'));
});

Now running the grunt command will create css/project.css containing your compiled Bootstrap code.

Upvotes: 1

Related Questions