Skip to content

new version generate style filename like app.css.2c9b54c9.css not app.2c9b54c9.css #66

Answered by doabit
nyrf asked this question in Q&A
Discussion options

You must be logged in to vote

Try add this codes to vite.config.js, i think it works

vite.config.js

  build: {
    rollupOptions: {
      output: {
        assetFileNames: (assetInfo) => {
          let name = assetInfo.name
          const reg = /(\.\w+)\.css$/
          const result = reg.exec(name)
          if (result) {
            name = name.replace(result[0], '')
          } else {
            name = name.substr(0, name.lastIndexOf('.'))
          }
          return `assets/${name}.[hash][extname]`
        }
      }
    }
  }

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@nyrf
Comment options

@ElMassimo
Comment options

@nyrf
Comment options

Comment options

You must be logged in to vote
3 replies
@nyrf
Comment options

@ElMassimo
Comment options

@doabit
Comment options

Answer selected by nyrf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants