Git Product home page Git Product logo

Comments (7)

pgilad avatar pgilad commented on August 28, 2024

Yeah that should exactly as you want it, see https://github.com/pgilad/grunt-jade-usemin/blob/master/test/test.js#L44-L55

Basically the configuration you need to have in your Gruntfile.js:

jadeUsemin: {
        build: {
            options: {
                tasks: {
                     tasks: {
                       js: ['concat', 'uglify', 'filerev'],
                       css: ['concat', 'cssmin']
                    }
                },
                dirTasks: ['filerev'],
                prefix:'public/' //public is a mount in express
            },
            files: [{
                dest: './build/views/layout.jade',
                src: './build/views/layout.jade'
            }]
        }
    }

Try that out and let me know how it works (it's a new feature introduced in 0.5.0)

from grunt-jade-usemin.

ryleyb avatar ryleyb commented on August 28, 2024

Yeah, so in that case I start getting these errors:

Running "concat:jadeUsemin-js" (concat) task
Warning: Unable to create directory "/javascripts" (Error code: EACCES). Use --force to continue.

Which is because of how the targets are setup in layout.jade, they don't know about /public nor about ./build/public.

from grunt-jade-usemin.

pgilad avatar pgilad commented on August 28, 2024

This looks like a problem with the prefix option. I'm going to test it out, in the meantime - can you try inlining the public prefix into the scripts to see if it works? (and don't forget to remove it as an option)

Edit
Actually I tested the prefix option, and it works. The problem is that the prefix isn't added to the targetPath of the script (this is in the works for a PR, see #11)

So in the target path of your script, you'll need to write the full output path, i.e:
src='build/public/javascripts/lib/jquery.min.js'

from grunt-jade-usemin.

ryleyb avatar ryleyb commented on August 28, 2024

Right. Yeah, I was just getting to this now, and I see that's the case. It works as expected if I setup my build block like so:

    //-<!-- build:js build/public/javascripts/lib/jquery.min.js -->
    script(src='/javascripts/lib/jquery.js')
    //-<!-- endbuild -->

Which gets me this in the output:

script(src='build/public/javascripts/lib/jquery.min.f6094334.js')

Which is good, progress, but that URI is definitely bogus in the app. It needs to be without build/public, and it looks like what you're saying is that with targetPrefix in #11, I might get where I need to be?

from grunt-jade-usemin.

pgilad avatar pgilad commented on August 28, 2024

I added the targetPrefix option to be used exactly as prefix but for target scripts. Can you try using it (with version 0.5.2) and see if it's working for you?

from grunt-jade-usemin.

ryleyb avatar ryleyb commented on August 28, 2024

Looks good! Thanks, Gilad...

from grunt-jade-usemin.

pgilad avatar pgilad commented on August 28, 2024

👍

from grunt-jade-usemin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.