Question

For whatever reason I cannot get usemin to write the output below is grunt file code. Its very straightforward

module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-usemin');


grunt.initConfig(
    {
        useminPrepare: {
            html: 'app/index.html',
            options: {
                dest: '/dist',
                root: 'app'
            }
        }
    }
);

grunt.registerTask('build', ['useminPrepare']);

};

It seems simple enough and my directory structure is as follows

|
+- app
|   +- index.html
|   +- assets
|       +- js
|          +- foo.js
|          +- bar.js
+- dist

when I run > grunt useminPrepare I get the configuration output Am I supposed to do something with the configuration out? Am I supposed to copy it anywhere. I expect that the dist folder would be created by running the task but it is not

I would expect this

|
+- app
|   +- index.html
|   +- assets
|       +- js
|          +- foo.js
|          +- bar.js
+- dist   ///this should be created but it isn't and i have no idea why???

My HTML is the following

<html>
<body>

 <!-- build:js assets/js/optimized.js -->
 <script src="assets/js/foo.js"></script>
 <script src="assets/js/bar.js"></script>
 <!-- endbuild -->

 </body> 
</html>
Was it helpful?

Solution

Honest to god I looked everywhere and finally saw the same quesition on github. The answer is that you need to specify the tasks they dont get called by useminPrepare in other words I need to make my task like this

grunt.registerTask('build', [ 'useminPrepare', 'concat', 'uglify']);

instead of

grunt.registerTask('build', [ 'useminPrepare']);

The answer was incredibly frustrating because it is nowhere in the documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top