Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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 网页包加载程序语法-带查询的数组_Webpack_Webpack 2 - Fatal编程技术网

Webpack 网页包加载程序语法-带查询的数组

Webpack 网页包加载程序语法-带查询的数组,webpack,webpack-2,Webpack,Webpack 2,从angular cli使用extract I生成的语法扩展到使用多个加载程序,其中一个加载程序需要查询字符串 使用数组语法并添加查询,如 // ... { "test":   /\.pug$/, "loader":  ['raw-loader', 'pug-html-loader'], "query":  { doctype: "html",  plugins:  ["pug-plugin-ng"] } }, // ... 不工作(这是有道理的,因为webpack不

从angular cli使用extract I生成的语法扩展到使用多个加载程序,其中一个加载程序需要查询字符串

使用数组语法并添加查询,如

// ...
{
    "test":   /\.pug$/,
    "loader":  ['raw-loader', 'pug-html-loader'],
    "query":  { doctype: "html",  plugins:  ["pug-plugin-ng"] }

},
// ...
不工作(这是有道理的,因为webpack不知道哪个加载程序应该使用查询


然而出于好奇,我胡闹了一下,试图重写配置,以便它能像这样清晰地配对

{
    "test":   /\.pug$/,
    "loader":  [
        'raw-loader',  
        {
            "loader":   'pug-html-loader',
            "query":  {  doctype:   "html",  plugins:  ["pug-plugin-ng"] }
        }
    ]
},
从来没有想过它会起作用。但令我惊讶的是它竟然起作用了!


当我试图找到一些关于这种语法的文档时,我发现正确的方法是

{
    "test":   /\.pug$/,
    use:  [
        'raw-loader',  
        {
            "loader":   'pug-html-loader',
            "options":  {  doctype:   "html",  plugins:  ["pug-plugin-ng"] }
        }
    ]
},
据报道




现在进入实际问题:第二种语法为什么有效?我在文档中找不到任何解释。

为了向后兼容,Webpack目前接受两种方式。 现在看来我们可以混合搭配,但将来可能会失败