pcardune / handlebars-loader

A handlebars template loader for webpack
551 stars 168 forks source link

Browser support #102

Open pbrain19 opened 7 years ago

pbrain19 commented 7 years ago

Currently switching from require js to webpack. I seem to have an issue with the way loads handlebars templates. It seems to be that the loader is wrapping the template in a function created for the frontend. is it possible that you can use the browser friendly version. Or is there something wrong with my config.

module.exports = {
    context: __dirname + '/web/src/js',
    entry: './v2/main/landing.js',
    exclude: /(node_modules|bower_components)/,
    output: {
        path: __dirname + '/web/dist/js/v2/main',
        filename: 'bundle.js',
    },
    externals: {
        // require("jquery") is external and available
        //  on the global var jQuery
        "jquery": "jQuery"
    },
    resolve: {
        root: __dirname + '/web/src/js',
        alias: {
            'handlebars': 'handlebars/dist/cjs/handlebars.js'
        }
    },
    module: {
        loaders: [
        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            loader: 'babel',
            query: {
                presets: ['es2015']
            }
        }, {
            test: /\.json$/,
            loader: 'json'
        }, {
            test: /\.html$/,
            loader: "handlebars-loader",
            query: {
                knownHelpers: ['tmplUserData']
            }
        }]
    }
}
vladperelmuter commented 7 years ago

👍

pbrain19 commented 7 years ago

👍

robsicat commented 7 years ago

👍

pcardune commented 7 years ago

Feel free to submit a pull request with a fix!