node package manager


convert a css file to DOM script format(inline stylesheet)


convert a css file into DOM script to inline style object

/* foo.css */
.foo {
    color: red;

will be converted to

// foo.css.js
(function () {
    var cssText = ".foo {\n" +
                  "    color:red;\n" +
    // some DOM script to inline style element

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-css2js

Then add this line to your project's Gruntfile.js gruntfile:


in Gruntfile.js:

    css2js: {
        foo: {
            src: 'src/foo.css',
            dest: 'dist/foo.css.js'
        bar: {
            src: [ 'src/bar/a.css', 'src/bar/b.css' ],
            dest: 'dist/bar.css.js'
  • beautify css injection snippet by @eastkiki
  • add a sample task into Gruntfile.js by @eastkiki
  • fixes issue with <cr><lf> line ended source files.
  • removes trailing a space.
  • handle escaped characters by @aoberoi
  • Support for grunt ~0.4.1
  • fixes issues with double quotes by @aoberoi

bump up version number to force updating readme in

first release

Copyright (c) 2013 Choi Seong-Rak
Licensed under the BSD license.