Webpack jade-html-loader

时间:2016-01-20 17:31:08

标签: javascript pug webpack

我正在使用webpack,我想用它来使用jade,目前我正在使用jade-html-laoder但是当我运行webpack watch命令时,HTML文件的结果附带了嵌入的所有javascript代码。

这是我的webpack.config.js

var webpack = require('webpack'),
    BrowserSyncPlugin = require('browser-sync-webpack-plugin'),
    html = require('jade-html-loader'),
    path = require('path');
  require('es6-promise').polyfill();



module.exports = {

    entry: ['./js/scripts.js', 'file?name=index.html!jade-html!./index.jade'],
    output: {filename: './js/bundle.js'},
    module: {
        loaders: [{
            test: /\.js?/,
            loader: 'babel-loader',
            exclude: /node_modules/
        },
    {
      test: /\.jade$/,
      loader: 'jade'
    },
        {
            test: /\.css$/,
            loader: "style!css"
        },
        {
            test: /\.scss$/,
            loaders: ["style", "css", "sass"]
        }]
    },


    plugins: [
        new BrowserSyncPlugin({
          host: 'localhost',
          port: 3000,
          server: {baseDir: './'},
          reload: true,
          files: "*.html"
        })
      ]
    };

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用新版本? 玉现在被称为哈巴狗。

威尔正在为我工​​作:

module: {
   loaders: [
       {
        test: /\.jade$/,
        loader: 'pug-html-loader'
       }
   ]
}