Vit*_*nov 6 javascript frontend vite
使用 Vite.js,是否可以选择“按原样”加载 javascript 文件?import"./_commonjsHelpers.80d8c10d.js"无需任何转换、缩小,也无需在文件开头注入类似内容。
我需要一个类似的加载原始脚本并将其包含在浏览器中的方法,就像使用简单<script>标签执行此操作一样。
尝试添加以下插件vite.config.js:
plugins: [{
name: 'static-js',
apply: 'serve',
enforce: 'pre',
resolveId(source, importer) {
if (source.endsWith('_commonjsHelpers.80d8c10d.js')) {
return '\ufeff' + source;
}
}
}]
Run Code Online (Sandbox Code Playgroud)