Webpack由于某种原因给我这个错误:
Regex
是不是因为在我的文件名中使用了“App”?
这是我的webpack.config.js文件:
<?php
ini_set('display_errors', 1);
$object= new DOMDocument();
$object->loadHTML('<html><body><script> <!-- discard --->
other stuff
not to be found
</script>
<script> <!-- MATCH --->
if (window.location.href == bar) {
do something
}
</script>
<script> <!-- discard --->
other stuff
not to be found
</script>
<script> <!-- discard --->
other stuff
not to be found
</script></body></html>');
$tagsToRemove=array();
foreach($object->getElementsByTagName("script") as $element)
{
if($element instanceof DOMElement)
{
if(!preg_match("/if\s*\(/i", $element->nodeValue))
{
$tagsToRemove[]=$element;
}
}
}
foreach($tagsToRemove as $element)
{
$element->parentNode->removeChild($element);
}
echo $object->saveHTML();
导致此错误的原因是什么?如何解决?
答案 0 :(得分:8)
这是因为你有2个条目(app.js,index.html)输出到同一个文件appN.js.尝试在输出的文件名中添加[name]。
另一个选择是删除条目中的index.html。并使用copy wepack插件将其添加到dist文件夹中。 https://github.com/kevlened/copy-webpack-plugin