I get an error after I start gulp. I have taken out all other plugins to find problem:
[gulp-sass] source string:1: error: invalid top-level expression
gulpfile.js:
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function() {
gulp.src('app/assets/sass/styles.sass')
.pipe(sass({
errLogToConsole: true
}))
.pipe(gulp.dest('public_html/assets/css'))
});
gulp.task('default', ['sass'], function() {
gulp.watch("app/assets/sass/*.sass", ['sass']);
});
Windows 7
Although a few utilities are provided to simplify working with the filesystem and command line, everything else you write is pure JavaScript. A gulpfile is a file in your project directory titled gulpfile.js (or capitalized as Gulpfile.js, like Makefile), that automatically loads when you run the gulp command.
Working with Gulp, you begin to run into a slightly annoying problem, and that is how gulp handles errors. If you mess up your code, Gulp plugins will not be sure what to do and will return an error. Once the error is returned, Gulp logs it and break the stream. In order to fix the error, you will have to fix the error, then restart your stream.
Here’s an example file structure using the WordPress file structure: You could add the gulp file into your theme folder or your wp-content folder instead. However, since I keep the wp-content file in my git repository as a whole, I keep the gulpfile.js file outside of my git repository by keeping it in the root of the project.
2) Minify the javascript into an all-min.js file. 3) Leave the resulting file in the /js folder. Open the Console, navigate to the folder that gulpfile.js is in, and type “gulp watch”. In the watch task, we allow the computer to watch for changes and run these tasks anytime they apply.
If you want to use the indented syntax (.sass) as the top level file, use
pipe(sass({ indentedSyntax: true }))
instead of
pipe(sass())
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With