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

请教一个问题:在401.vue文件中import 静态文件语法错,导致build不过 #61

Closed
Airpy opened this issue May 25, 2019 · 14 comments

Comments

@Airpy
Copy link

Airpy commented May 25, 2019

import errGif from "@/assets/401_images/401.gif";

这行,我在npm run build的时候,提示找不到对应的文件,静态文件没有export能import xxx from??

@Armour
Copy link
Owner

Armour commented May 25, 2019

@Airpy
Copy link
Author

Airpy commented May 26, 2019 via email

@Armour
Copy link
Owner

Armour commented May 26, 2019

vue-cli 默认自带的image import配置是这样的:

...
      /* config.module.rule('images') */
      {
        test: /\.(png|jpe?g|gif|webp)(\?.*)?$/,
        use: [
          /* config.module.rule('images').use('url-loader') */
          {
            loader: 'url-loader',
            options: {
              limit: 4096,
              fallback: {
                loader: 'file-loader',
                options: {
                  name: 'img/[name].[hash:8].[ext]'
                }
              }
            }
          }
        ]
      },
...

file-loader 一般都是可以的 其次你要确定下你的代码 1.支不支持import (es6) 2.路径对不对(是不是解析有问题 没找到正确路径)

@Armour
Copy link
Owner

Armour commented May 26, 2019

对于我这个项目用的vue-cli自动生成的config 你试试 vue inspect 会打印出webpack的配置详情

@Armour
Copy link
Owner

Armour commented May 26, 2019

另外几点:

  1. @的解析
resolve: {
    alias: {
      '@': '/Users/chongguo/Github/vue-typescript-admin-template/src',
      vue$: 'vue/dist/vue.runtime.esm.js'
    },
}
  1. gif type definition
    declare module '*.gif' {

@Airpy
Copy link
Author

Airpy commented May 26, 2019 via email

@Armour
Copy link
Owner

Armour commented May 26, 2019

一般这种问题最好给个可复现的最小例子 比如你的GitHub repo

@Armour
Copy link
Owner

Armour commented May 26, 2019

如果你完全没有改的话 理论上应该不会发生这样的问题 只可能是环境的问题了 比如操作系统 npm版本 等等

@Airpy
Copy link
Author

Airpy commented May 26, 2019 via email

@Armour
Copy link
Owner

Armour commented May 26, 2019

emm 因为这是我去年年底才开始写的项目 所以暂时没有群 不过我正打算建一个 我现在建吧 然后我会尽量回答大家的问题 之后也会更新一波typescript版本的文档的

@Armour
Copy link
Owner

Armour commented May 26, 2019

image

先用这个吧 我随便拉了几个朋友hh

@Armour
Copy link
Owner

Armour commented May 26, 2019

暂时先关了 可以群里讨论

@Armour Armour closed this as completed May 26, 2019
@ty793941
Copy link

二维码已过期,能否再给一下

@Armour
Copy link
Owner

Armour commented Apr 26, 2020

二维码已过期,能否再给一下

#62

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