feat: migrate scaffolding to vite
This commit is contained in:
1
src/config/vite.config.js
Normal file
1
src/config/vite.config.js
Normal file
@@ -0,0 +1 @@
|
||||
// Placeholder for vite.config.js
|
||||
@@ -1 +0,0 @@
|
||||
// Placeholder for webpack.config.js
|
||||
@@ -1,27 +1,15 @@
|
||||
const deps = [
|
||||
'react',
|
||||
'react-dom',
|
||||
'@babel/core',
|
||||
'@babel/preset-env',
|
||||
'webpack-cli',
|
||||
'webpack',
|
||||
'web-vitals',
|
||||
'typescript',
|
||||
'style-loader',
|
||||
'react-scripts',
|
||||
'react-dom',
|
||||
'react',
|
||||
'jest',
|
||||
'babel-loader',
|
||||
'ajv',
|
||||
'@types/react-dom',
|
||||
'@types/react',
|
||||
'@types/node',
|
||||
'@types/jest',
|
||||
'@testing-library/user-event',
|
||||
'@testing-library/react',
|
||||
'@testing-library/jest-dom',
|
||||
'@babel/preset-react',
|
||||
'@testing-library/jest-dom'
|
||||
];
|
||||
|
||||
module.exports = { deps };
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
const devDeps = [
|
||||
'pretty-quick',
|
||||
'webpack-dev-server',
|
||||
'url-loader',
|
||||
'vite',
|
||||
'@vitejs/plugin-react',
|
||||
'husky',
|
||||
'dotenv-webpack',
|
||||
'dotenv',
|
||||
'@svgr/webpack',
|
||||
'@commitlint/config-conventional',
|
||||
'@commitlint/cli',
|
||||
'prettier',
|
||||
'ora',
|
||||
'@babel/plugin-proposal-private-property-in-object',
|
||||
'@babel/plugin-proposal-private-property-in-object'
|
||||
];
|
||||
|
||||
module.exports = { devDeps };
|
||||
|
||||
@@ -24,15 +24,15 @@ async function initProject(projectDirectory, userInput, options) {
|
||||
|
||||
console.log(`🚀 Creating a new React app in ${root}...`);
|
||||
|
||||
const spinner = ora('Installing base Create React App...').start();
|
||||
const spinner = ora('Installing base Vite React App...').start();
|
||||
|
||||
try {
|
||||
// Initialize CRA with or without TypeScript
|
||||
const template = userInput.language === 'TypeScript' ? '--template typescript' : '';
|
||||
execSync(`npx create-react-app . ${template} ${verboseFlag}`, { stdio: 'inherit' });
|
||||
spinner.succeed('✅ Base React app created successfully.');
|
||||
// Initialize Vite with or without TypeScript
|
||||
const template = userInput.language === 'TypeScript' ? '--template react-ts' : '--template react';
|
||||
execSync(`npm create vite@latest . ${template} ${verboseFlag}`, { stdio: 'inherit' });
|
||||
spinner.succeed('✅ Base Vite app created successfully.');
|
||||
} catch (error) {
|
||||
spinner.fail('❌ Failed to create base React app.');
|
||||
spinner.fail('❌ Failed to create base Vite app.');
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// Placeholder for packageJson.js
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const ora = require('ora');
|
||||
|
||||
function updatePackageJson() {
|
||||
const spinner = ora(
|
||||
'📝 Updating package.json with custom scripts...'
|
||||
@@ -8,15 +12,14 @@ function updatePackageJson() {
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
|
||||
packageJson.scripts = {
|
||||
start: 'webpack serve --config webpack.config.js --mode development',
|
||||
build: 'webpack --config webpack.config.js --mode production',
|
||||
dev: 'vite',
|
||||
build: 'vite build',
|
||||
preview: 'vite preview',
|
||||
test: 'echo "Error: no test specified" && exit 0',
|
||||
'test:dev': 'react-scripts test',
|
||||
'pretty-quick': 'pretty-quick',
|
||||
'lint:prettier': 'node check-format.js',
|
||||
prettier: 'prettier --write . --config .prettierrc',
|
||||
'prettier:commit': 'node prettier-commit.js',
|
||||
eject: 'react-scripts eject',
|
||||
prepare: 'husky install',
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user