English | 中文
Provide some plug-ins required on vite parser, and now realize the following functions
1.Make vite work normally in webpackexternals
External dependencies in configuration items
2.Solve the problem that the JSX
file in vite fails to parse due to the loss of Lang tag
npm i vite-plugin-resolver -D
All methods are configured in vite.config.js
import { externals } from 'vite-plugin-resolver'
export default {
plugins: [
// externals(/* options */)
externals({
vue: 'Vue',
react: 'React',
'react-dom': 'ReactDOM',
}),
]
}
Type: Object
Default: { externals: Record<String, String> }
Type: String
Default: 'esm' | 'cjs'
esm will generate code - const vue = window['Vue']; export { vue as default }; cjs will generate code - const vue = window['Vue']; module.exports = vue;
import { andLang } from 'vite-plugin-resolver'
export default {
plugins: [
andLang(),
]
}