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

webpack如何处理rgl文件中的图片路径 #1

Open
Adamwu1992 opened this issue Sep 30, 2017 · 1 comment
Open

webpack如何处理rgl文件中的图片路径 #1

Adamwu1992 opened this issue Sep 30, 2017 · 1 comment

Comments

@Adamwu1992
Copy link

你好,我司最近有一个项目使用的是regularjs+regular-ui实现的,当初使用的是gulp打包,接下来需求增多想切换到webpack,参照你的例子把原先写在<script type="text/regular"></script>里的模板都写到了rgl文件里,遇到一个问题就是在模版里写的图片路径不能被webpack正确加载

  • 问题重现步骤
    这个是rgl文件里的代码
<li>
    <div>
        <i class='instructions-number'>1</i>
        <p>进入财务会计——报表管理——报表编制——报表制作,如下图所示:</p>
    </div>
    <img src='../images/instructions/jdPrompt1.png' alt='导出操作说明' />
</li>

这个是引用的代码

import JsPrompt from '../components/jsPrompt.rgl';
...
common.dialog({
    title: "导出操作说明",
    contentTemplate: JsPrompt
});

这个是webpack配置

module: {
        rules: [{
            test: /\.js$/,
            use: ['babel-loader'],
            include: [sourcePath]
        }, {
            test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
            use: [{
                loader: 'url-loader',
                options: {
                    name: utils.assetsPath('/[name].[ext]?[hash]'),
                    publicPath: '../../../',
                    useRelativePath: process.env.NODE_ENV === "production"
                }
            }],
        }, {
            test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/,
            use: [{
                loader: 'url-loader',
                options: {
                    name: utils.assetsPath('/images/[name].[ext]?[hash]'),
                    publicPath: '../../../',
                    useRelativePath: process.env.NODE_ENV === "production"
                }
            }]
        }, {
            test: /\.html$/,
            loader: 'html-loader'
        }, {
            test: /\.rgl(\?\S*)?$/,
            loader: 'rgl-loader'
        }, {
            test: '/\.xls$/',
            loader: ExtractTextPlugin('url-loader')
        }]
    },
  • 期待的结果是什么?实际又是什么?
    期望所有图片都被转码;
    实际是:定义在html和css中的图片都转成了base64,但是rgl里的图片还是保留的相对路径

  • 使用的版本是什么?在什么操作系统上?
    这是package.json的信息

    "regular-ui": "^0.1.8",
    "regularjs": "^0.6.0-beta.6",

node: v7.6.0
webpack: 3.0.0
macOS: 10.12.6

@fengzilong
Copy link
Member

issue描述很详尽👍

rgl-loader目前没处理这个,国庆后我提个pr

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

2 participants