riot / rollup-plugin-riot

Rollup Plugin for Riot
https://www.npmjs.com/package/rollup-plugin-riot
MIT License
26 stars 9 forks source link

how to use it with pug templates #103

Closed revington closed 5 years ago

revington commented 6 years ago

Got an error while processing a pug tag. In my rollup.config.js I'm passing template:'pug' as a parser option. pug is installed globally on my machine.

[!] Error: Unexpected token                                                                                                                 
src/tags/signup/template.static.pug (3:16)                                                                                                  
1: import riot from 'riot';signup                                                                                                           
2:     script
3:         include signup.js
                   ^
4:     form(onsubmit="{doSignUp}")
5:         .form-group
function inputFileToConfig(input) {
    var ret = {
        entry: input,
        dest: input.replace('src', 'build'),
        format: 'iife',
        sourceMap: 'inline',
        plugins: [
            resolve({
                jsnext: true,
                main: true,
                browser: true,
            }),
            commonjs(),
            riot({
                ext: 'pug',
                parserOptions: {
                    template: 'pug'
                }
            }),
            replace({
                'process.env.NODE_ENV': JSON.stringify('')
            }),
        ]
    }
    return ret;
};
module.exports = inputFiles.map(inputFileToConfig);
GianlucaGuarini commented 5 years ago

this package should work with your local dependencies and not with the global ones installed on your machine. For v4.0.0 you will need to register your preprocessor https://github.com/riot/compiler#registerpreprocessortype-id-preprocessorfn