vite-plugin-replace-require-variable
v1.1.3
Published
Converts the require function that contains variables
Downloads
30
Readme
vite-plugin-replace-require-variable
Vite + Vue2 project
Situation
/* v1.0.x just support ([email protected])*/
require(("../../assets/img/" + _vm.filePath + ".png"))
/* v1.1.x after support [email protected] */
require("../../assets/img/icon_".concat(_vm.fileType, ".png"))
require(`../../assets/img/icon_${_vm.fileType}.png`)
Install
npm install vite-plugin-replace-require-variable -D
/* vite.config.js */
import { replaceRequireVariable } from 'vite-plugin-replace-require-variable'
export default defineConfig({
plugins: [
{
replaceRequireVariable(/* options */)
}
]
})
Options
- Type: Array
- Default: [] /* eg. ['xxx.vue'].*/
Result
import a from "b"
const obj = {
"b": a
}
let varibles = obj["b"]