S
S
SvinkaBacilka2020-05-13 11:48:16
JavaScript
SvinkaBacilka, 2020-05-13 11:48:16

How to set paths for files by type publicPath?

There is an application that is not deployed in the root of the domain and has the following setting in vue.confi.js:

publicPath: process.env.NODE_ENV === 'production'
    ? '/subpath/'
    : '/'


How do I access files by relative path that are in the folder, publictaking into account '/subpath/' where the application is deployed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SvinkaBacilka, 2020-05-17
@SvinkaBacilka

I solved this problem as follows:
Since Webpack, under the hood of vue-cli, does not process the data in the public folder in any way, but simply copies them , I had to explicitly access the publicPath variable from the script:
`${process.env.BASE_URL}path/you/need/file/png`

B
bubaley, 2020-05-13
@bubaley

Hello

outputDir: '../static/dist',
publicPath: process.env.NODE_ENV === 'production'
    ? '/static/dist/'
    : '/',
indexPath: process.env.NODE_ENV === 'production'
    ? '../../templates/index.html'
    : 'index.html',

With this functionality, you can customize the places where the build is going to.
outputDir - Specifies the directory in which to build the project.
publicPath - Adds a prefix to index.html where to get files from.
indexPath - the place where index.html will be.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question