chyingp / grunt-inline

Brings externally referenced resources, such as js, css and images, into a single file.
MIT License
86 stars 55 forks source link

dont work for .hbs #29

Open Anisotropic opened 10 years ago

Anisotropic commented 10 years ago

Hello. i've tried to use this plugin for inlining CSS for handlebars templates, but it don't work. Handlebars templates - are HTML parts without . Maybe this cause the trouble?

chyingp commented 10 years ago

@Anisotropic any more details? Like error message printed? Try options.exts like bellow it may wokrs.

        dist: {
            options: {
                exts: ['hbs']
            },
            src: ['src/**/*.hbs']
        }

If it still doesn't work, please let me know :)

Anisotropic commented 10 years ago

Yes, it's still doesn't work.
Using this syntax not working:

        inline: {
            all:{
                    options:{
                        cssmin: true,
                        exts: ['hbs']
                    },
                    src: ['app/handlebars/standart.hbs'],
                    dest: ['.tmp/']
                }
              },

And this syntax not working:

    inline: {
            all:{
                    options:{
                        cssmin: true
                    },
                    src: ['app/handlebars/standart.hbs'],
                    dest: ['.tmp/'],
                     ext: '.hbs'
                }
              },

it copying hbs file without inlining. .hbs begin with this: `

.....`
chyingp commented 10 years ago

@Anisotropic there should be a __inline tag to tell grunt-inline that this stylesheet needs to be inlined , as the documentation says. Follow the example bellow, just try again :)

<link href="css/style.css?__inline=true" rel="stylesheet" />
Anisotropic commented 10 years ago

yes, my mistake. When i add this __inline tag, example from my past message are working. But this one:

inline: {
            all:{
                files: [{
                        expand: true,
                        cwd: 'app/handlebars/',
                        src: ['*.hbs'],
                        dest: '.tmp/handlebars/',
                        ext: '.hbs'
                    }],
                    options:{
                        cssmin: true,
                        exts: ['hbs']
                    },
                }
              },

Working as i'm no expect. It inlining all hbs files in /app/handlebars/, but i want it inlined in /.tmp/handlebars/

ghost commented 10 years ago

@Anisotropic I had the same problem with .ejs views. You solution works for me with .ejs.

Did you manage to inlined in the 'dest' folder ? Any solutions?

Anisotropic commented 10 years ago

@maxime-crunding I`ve solved this by using another inline plugin and divide this one action to some independent actions: 1 - copy .hbs to .tmp, 2 - copy & minifying .css to .tmp, 3 - inlining .css to .hbs, 4 - compiling & uglifying .hbs