vendredi 2 décembre 2016

Why html file doesn't see function in bundle.js?

Begin work with webpack and stack. My generated html file consist string with event onclick. But my html file doest't see function in generated file bundle.js. Bundle js file conected successfully(console.log works). But if i write <script>function bar()...</script> in html, onclick work. Help. Try connect file in head, beggining body, end of body/file - doesn't see function. Bundle.js generated from main.js:

require("path to css...");
function bar(){...};

String in html:

<div class="foo" onclick="bar()">...</div>

Bundle.js:

var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    entry: "./src/main.js",
    output: {
    path: "dist",
    filename: "bundle.js"
},

module: {
    loaders: [
    {
        test: /\.js$/,
        loader: "babel-loader",
        options: { presets: ["es2015"] }
     ,
    {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style','css')
    },
    {
        test: /\.jade$/,
        loader: "jade"
    }]
},
plugins: [
    new ExtractTextPlugin("main.css"),
    new HtmlWebpackPlugin({
        template: './src/jade/index.jade'
    })
]
};




Aucun commentaire:

Enregistrer un commentaire