Note that there are some explanatory texts on larger screens.

plurals
  1. POGrunt Inline CSS and Javascript
    primarykey
    data
    text
    <p><strong>Short Version:</strong> </p> <p>Is there a way, using Grunt, to include minified CSS and JavaScript inline? </p> <p>To use usemin's formatting as an example, I would like to see something like this: </p> <pre><code>&lt;!-- build:css inline --&gt; &lt;link rel="stylesheet" href="styles/foo.css"&gt; &lt;link rel="stylesheet" href="styles/bar.css"&gt; ... &lt;!-- endbuild --&gt; &lt;!-- build:js inline --&gt; &lt;script src="js/foo.js"&gt;&lt;/script&gt; &lt;script src="js/bar.js"&gt;&lt;/script&gt; ... &lt;!-- endbuild --&gt; </code></pre> <p>Turned into this something like this: </p> <pre><code>&lt;style&gt;body { color: red; } /*css is here*/&lt;/style&gt; &lt;script&gt;var foo = 1; bar = 'some javascript code is here'; ...&lt;/script&gt; </code></pre> <p><strong>Long Version:</strong> </p> <p>So, I'm working on a Tumblr theme. In order to use CSS or JS files in a theme, they have to be uploaded to Tumblr. The only way to upload is a crappy little web form that often crashes. I'm trying to avoid this interface until I'm ready to upload the final code because </p> <ol> <li>there's no way to delete uploaded files, and</li> <li>while I'm in the middle of development, these extra steps take too much time</li> </ol> <p>To get this, I've been copying my CSS and JS into <code>&lt;style&gt;</code> and <code>&lt;script&gt;</code> tags in my file, then copying the whole thing into the Tumblr theme editor. It's faster, so I'm happy with that, but manually copying and pasting CSS and JS into a file seems to go against the spirit of Grunt and the automation it provides. </p> <p>Ideally, I would be able to run <code>grunt build</code> and have it spit out an html file with the CSS and JS inline, then I can just copy that into the Tumblr interface (well, ideally, I would be able to copy that HTML file to Tumblr, but Tumblr doesn't provide FTP or SSH or any useful interface, so I'll settle for this). </p> <p>It seemed like <a href="https://github.com/yeoman/grunt-usemin" rel="nofollow"><code>grunt-usemin</code></a> could provide the functionality I'm looking for, but I haven't been able to get it working as I described. Maybe it's only made to put everything into a separate file. </p> <p>I'm open to using any Grunt tool if anyone knows of one that could accomplish this. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload