vite-plugin-react-js-support js文件转换失败
hdbaiyu opened this issue · 4 comments
(!) "base" option should end with a slash.
src/test.js:3:4: error: Unexpected "<"
3 │test ..... demo....
╵ ^
error when starting dev server:
Error: Build failed with 1 error:
src/test.js:3:4: error: Unexpected "<"
at failureErrorWithLog (/Documents/code/login/node_modules/esbuild/lib/main.js:1224:15)
react 版本17.*
麻烦提供下vite.config.js的配置文件
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import vitePluginImp from 'vite-plugin-imp';
import importReact from 'vite-react-jsx';
import vitePlugin from 'vite-plugin-react-js-support';
import theme from "./config/theme"
const path = require('path');
// const { REACT_APP_ENV } = process.env;
function resolve(dir: string) {
return path.join(__dirname, dir);
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [reactRefresh(),
importReact(),
vitePlugin(),
vitePluginImp({
libList: [
{
libName: "antd",
style: (name) => antd/es/${name}/style
,
},
],
}),
],
css: {
preprocessorOptions: {
less: {
// 支持内联 JavaScript
javascriptEnabled: true,
// 配置 antd 的主题颜色
modifyVars: theme,
}
},
},
base: '/',
resolve: {
alias: {
'@': resolve('src'),
'@assets': resolve('assets')
}
},
server: {
port: 8081,
}
})