Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 2 帕格本地人汇编与网页_Webpack 2_Html Webpack Plugin_Pug Loader - Fatal编程技术网

Webpack 2 帕格本地人汇编与网页

Webpack 2 帕格本地人汇编与网页,webpack-2,html-webpack-plugin,pug-loader,Webpack 2,Html Webpack Plugin,Pug Loader,我对帕格和网页2有问题。我需要编译并包含函数传递的另一个文件 //- index.jade //- I'm using bemto mixin foo() //- simplified example - var blockName = 'some-block' +b.some-block != getBlock(blockName) //- same bad result //- != htmlWebpackPlugin.options.getBlock(b

我对帕格和网页2有问题。我需要编译并包含函数传递的另一个文件

//- index.jade
//- I'm using bemto
mixin foo()
  //- simplified example
  - var blockName = 'some-block'
  +b.some-block
    != getBlock(blockName)
    //- same bad result
    //- != htmlWebpackPlugin.options.getBlock(blockName)
+foo()

//- some-block.pug
+e.element Some text

// webpack.config.js
use: [
  'html-loader', // without it shows an error
  {
    loader: "pug-html-loader",
    options: {
      data: {
        getBlock: function(blockName) {
          return fs.readFileSync(`${blockName}.pug`, { encoding: 'utf8' });
        },
      }
    }
  }
]
new HtmlWebpackPlugin({
  filename: index.html,
  template: index.pug,
  // same bad result
  // getBlock: function(blockName) {
  // return fs.readFileSync(`${blockName}.pug`, { encoding: 'utf8' });
  // },
})
我得到的是:

// index.html
<div class="some-block">+e.element Some text</div>
//index.html
+e、 给一些文本添加元素
我需要的是:

// index.html
<div class="some-block">
  <div class="some-block__element">Some text</div>
</div>
//index.html
一些文本
这可能吗?如果你能帮助我,我将不胜感激