aui / art-template-loader

art-template loader for webpack
MIT License
107 stars 33 forks source link

关于 htmlResourceRules的问题 #16

Closed icaife closed 7 years ago

icaife commented 7 years ago

配置

    htmlResourceRules: [
            /<(?:link|script|img)[^>]+\b(?:(?:data|original)-)?(?:src|href)="([^"]*)"/img,
    ]
plugins使用了 HtmlWebpackPlugin 生成html页面。

页面

    <script src="./index.js"></script>
    <link rel="stylesheet" href="./index.less">

版本

        "art-template": "^4.12.1",
        "art-template-loader": "^1.4.3",
        "webpack": "^3.1.0",
        "html-webpack-plugin": "^2.29.0",

报错信息

ERROR in Template execution failed: ReferenceError: window is not defined

ERROR in   ReferenceError: window is not defined

  - 15:23 eval
    webpack-internal:///15:23:2

  - 15:12 eval
    webpack-internal:///15:12:46

  - 15:57 module.exports
    webpack-internal:///15:57:46

  - 33:12 eval
    webpack-internal:///33:12:37

  - index.html:885 Object.<anonymous>
    D:/work/tffview/src/account/index/index.html:885:1

  - index.html:631 __webpack_require__
    D:/work/tffview/src/account/index/index.html:631:30

  - index.html:49 fn
    D:/work/tffview/src/account/index/index.html:49:20

  - 29:3 Object.eval
    webpack-internal:///29:3:1

  - 29:33 eval
    webpack-internal:///29:33:30

  - index.html:861 Object.<anonymous>
    D:/work/tffview/src/account/index/index.html:861:1

  - From previous event:

  - index.js:280 HtmlWebpackPlugin.executeTemplate
    [tailor]/[html-webpack-plugin]/index.js:280:10

  - index.js:140
    [tailor]/[html-webpack-plugin]/index.js:140:91

  - From previous event:

  - index.js:137 Compiler.<anonymous>
    [tailor]/[html-webpack-plugin]/index.js:137:14
aui commented 7 years ago

需要提供 demo

aui commented 7 years ago

你的 demo 没有 package.json 文件,我无法运行。

另外,demo 中请移除无关的代码,只做为重现问题用,而不是将一大堆环境相关的让我帮你逐一排除问题 :)

icaife commented 7 years ago

get