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

assetsDir can not use the relative Path '../' #5627

Closed
7 tasks done
xianchenxy opened this issue Nov 11, 2021 · 7 comments
Closed
7 tasks done

assetsDir can not use the relative Path '../' #5627

xianchenxy opened this issue Nov 11, 2021 · 7 comments

Comments

@xianchenxy
Copy link

xianchenxy commented Nov 11, 2021

Describe the bug

it works in development. Terminal report an error when i used build command.

The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../iconfont.a2bfd5b8.eot".

Reproduction

This is details about the error message.
image

I can't find the font.xxx.css file in my project, so i try to annotate related code, such as
image

then build again. but it still report error, see
image

vite.config.js

import { defineConfig } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
import path from 'path'

export default defineConfig({
  server: ...,
  clearScreen: false,
  resolve: {
    alias: {
      'src': path.resolve(__dirname, 'src'),
      '@': path.resolve(__dirname, 'src')
    }
  },
  build: {
    target: 'chrome58',
    outDir: '../gameanalytics/server/trunk/app/public',
    assetsDir: '../',
    chunkSizeWarningLimit: '400',
  },
  plugins: [createVuePlugin({ jsx: true }), viteCommonjs()]
})

packjson.json

{
  "name": "vite-test",
  "version": "1.0.0",
  "description": "pretest",
  "main": "main.js",
  "scripts": {
    "test": "no",
    "dev": "vite",
    "serve": "vite preview",
    "build": "vite build"
  },
  "keywords": [
    "vite"
  ],
  "author": "xianchenxy",
  "license": "ISC",
  "devDependencies": {
    "@originjs/vite-plugin-commonjs": "^1.0.1",
    "sass": "^1.43.4",
    "socket.io-client": "^4.3.2",
    "vite": "^2.6.13",
    "vite-plugin-vue2": "^1.9.0"
  },
  "dependencies": {
    "@vue/composition-api": "^1.3.3",
    "echarts": "^5.2.2",
    "element-ui": "^2.15.6",
    "eslint": "^8.1.0",
    "exceljs": "^4.3.0",
    "file-saver": "^2.0.5",
    "jquery": "^3.6.0",
    "lodash-es": "^4.17.21",
    "pinyin-match": "^1.2.2",
    "vue": "^2.6.14",
    "vue-i18n": "^8.26.7",
    "vue-resource": "^1.5.3",
    "vue-router": "^3.5.3",
    "vuedraggable": "^2.24.3",
    "vuex": "^3.6.2",
    "vuex-router-sync": "^5.0.0"
  }
}

System Info

System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Memory: 8.78 GB / 15.88 GB
  Binaries:
    Node: 14.17.5 - C:\Program Files\nodejs\node.EXE
    npm: 7.20.3 - D:\nodejs\node_global\npm.CMD
  Browsers:
    Edge: Spartan (44.18362.267.0)
    Internet Explorer: 11.0.18362.1

Used Package Manager

npm

Logs

[vite:css] The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../iconfont.a2bfd5b8.eot".

after annotating code, then build again.
----------------------------------------------------------------------------------------------------------
[vite:css] The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../element-icons.ab40a589.woff".

Validations

@ygj6
Copy link
Member

ygj6 commented Nov 11, 2021

Can you check if this is a duplicate of #5047? It is best to provide a minimal replication repo

@github-actions
Copy link

Hello @xianchenxy. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@xianchenxy
Copy link
Author

Can you check if this is a duplicate of #5047? It is best to provide a minimal replication repo

No, it isn't. I found this error was caused by assetsDir: '../'. After removing that, it is OK.
This is what I want.

assets: 'app/public/'
index.html: 'app/view/index.html'

However, Where can I find the config like indexPath in webpack?
@ygj6

@ygj6
Copy link
Member

ygj6 commented Nov 15, 2021

@xianchenxy As far as I know, assetsDir is relative to outDir, and there is no simple configuration to output assets outside of outDir. It can be achieved using plugins but is more complicated, you can try

@xianchenxy
Copy link
Author

xianchenxy commented Nov 15, 2021

@ygj6 You're right. I try my best to fix the problem, but no effect. So I have to ask back-end developer to update the config for index.html in server to resolve the problem. Anyway, Thanks a lot! 🌹

@xianchenxy xianchenxy changed the title Can't deal with the iconfont.css when i build assetsDir can not use the relative Path '../' Nov 15, 2021
@Huauauaa
Copy link

@xianchenxy As far as I know, assetsDir is relative to outDir, and there is no simple configuration to output assets outside of outDir. It can be achieved using plugins but is more complicated, you can try

@ygj6 Could you recommend some plugins?

@ygj6
Copy link
Member

ygj6 commented Nov 26, 2021

@Huauauaa oops, this is really an edge use case, I haven't found one so far. Maybe you can write one to publish and make it famous. Or I can try till i'm in spare.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants