Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt gives a weird "WARN: ERROR: Unexpected token..." message

I'm setting up grunt minification tasks for the following css file named "test.css":

body{
 background-color: #fff;
 text-align: left;
}

I get the following message when I run grunt:

WARN: ERROR: Unexpected token: punc ({) [test.css:1,4]

My "Gruntfile.js" file currently looks like this:

module.exports = function(grunt) {
  grunt.initConfig({
  pkg: grunt.file.readJSON('package.json'),
  uglify: {
    options: {
      banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
    },
    min: {
      src: 'test.css',
      dest: 'test.min.css'
    }
  }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.registerTask('default', ['uglify']);
};

My "package.json" file currently looks like this:

{
  "name": "kaidez",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.0",
    "grunt-contrib-uglify": "~0.1.1"
  }
}

Running grunt v4.0 and node v0.8.20, both installed globally. Both grunt-cli and uglify are installed. "Gruntfile.js", "package.json" and "test.css" are in the same directory. All of these files are in the "themes" directory for a WordPress site, but I don't that's the issue.

Any ideas?

like image 590
kaidez Avatar asked Feb 24 '13 22:02

kaidez


1 Answers

The uglify task is only for JavaScript files. For CSS, checkout this answer, which suggests grunt-css (cit Jonathan Lonowski comment)

like image 102
Antonello Pasella Avatar answered Oct 22 '22 00:10

Antonello Pasella