There are grunt plugins that already do stuff like that: https://github.com/jgallen23/grunt-inline-css // https://npmjs.org/package/grunt-inline