S
S
Swartex2019-09-03 16:18:37
webpack
Swartex, 2019-09-03 16:18:37

How to force webpack to add folder name to image path?

I'm using vue-cli3 for a project, but I needed to change the path to static files when building the project.
there is such a configuration

// vue.config.js
module.exports = {
    chainWebpack: config => {
        if(config.plugins.has('extract-css')) {
            const extractCSSPlugin = config.plugin('extract-css')
            extractCSSPlugin && extractCSSPlugin.tap(() => [{
                filename: '[name].css',
                chunkFilename: '[name].css'
            }])
        }
        config.optimization.delete('splitChunks')
    },
    configureWebpack: {
        output: {
            filename: '[name].js',
            chunkFilename: '[name].js',
        },

    },
    lintOnSave: true,
    filenameHashing: false,
}

How can I add that the path to the image during assembly would not be the default img/myawesomimg.png ,
but would be /work-dir/assets/myawesomimg.png Or
use a relative path. because above the /work-dir/ folder there is also a
publicPath configuration folder and assetsDir tried the result 0.
Sorry for the confusion, but I’ve been sitting for a couple of hours and I can’t configure

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question