Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html页面里有iframe时,打包后脚本跑到iframe里去了 #66

Open
zhuzhuaicoding opened this issue Jul 27, 2016 · 2 comments
Open

Comments

@zhuzhuaicoding
Copy link

fis.match('::package', {
        spriter: fis.plugin('csssprites'),
        postpackager: fis.plugin('loader', {
            allInOne: {
                includeAsyncs: true,
                js: function(file) {
                    return "static/" + file.filename + ".js";
                },
                css: function(file) {
                    return "static/" + file.filename + ".css";
                },
                sourceMap: true //是否生成依赖map文件
            },
            resourcemapWhitespace: 4
        })
    })

test.html

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="Description" content="" />
        <meta name="Keywords" content="" />
        <title>数据门户</title>
    </head>
    <body>
        <div class="wrapper" id='main_top'>
            <div class="pub_box">
                <div class="pub_box_t">
                    <h2>批量添加</h2>
                    <div class="title_right_box"><a class="batch_add_demo" href="/ch/download/manager/pcwap_cid.xlsx">下载模版</a></div>
                </div>
                <div class="pub_box_c batch_add">
                    <iframe id="iframe_upload_box" width="0" height="0" style="display: none" name="iframe_upload_box" src="">
                        <html>
                            <head></head>
                            <body></body>
                        </html>
                    </iframe>
                </div>
            </div>

        </div>
        <script>
            require.async(['app.js'])
        </script>
    </body>
</html>

output

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="Description" content="" />
        <meta name="Keywords" content="" />
        <title>数据门户</title>


</head>
    <body>
        <div class="wrapper" id='main_top'>
            <div class="pub_box">
                <div class="pub_box_t">
                    <h2>批量添加</h2>
                    <div class="title_right_box"><a class="batch_add_demo" href="/ch/download/manager/pcwap_cid.xlsx">下载模版</a></div>
                </div>
                <div class="pub_box_c batch_add">
                    <iframe id="iframe_upload_box" width="0" height="0" style="display: none" name="iframe_upload_box" src="">
                        <html>
                            <head>undefined
                            <body>
<script>
            require.async(['app.js'])
        </script>
</body>
                        </html>
                    </iframe>
                </div>
            </div>

        </div>
    undefined
</html>

为啥我的脚本跑到iframe里面去了呢?

@zhuzhuaicoding zhuzhuaicoding changed the title html页面里有iframe时,打包脚本会有问题 html页面里有iframe时,打包后脚本跑到iframe里去了 Jul 27, 2016
@MarvinXu
Copy link

没人解决吗? 好像是跟body标签有关,我的模板碎片里没有body,产出没有js引用

@2betop
Copy link
Contributor

2betop commented Nov 28, 2016

没有 body 标签的自己加 placeholder 。 https://github.com/fex-team/fis3-postpackager-loader/blob/master/index.js#L117-L125

楼主的问题应该也能用这个方式解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants