@@ -19,17 +19,17 @@ const defaultStyles = [
1919] ;
2020
2121const getExtension = ( appPath ) => {
22- return fs . existsSync ( path . join ( appPath , 'src' , 'App.tsx' ) ) ? '.tsx' : '.js ' ;
22+ return fs . existsSync ( path . join ( appPath , 'src' , 'App.tsx' ) ) ? '.tsx' : '.jsx ' ;
2323} ;
2424
2525const pathToPagesIndex = ( ) => {
2626 const extension = getExtension ( process . cwd ( ) ) ;
2727 return path . join ( process . cwd ( ) , 'src' , 'pages' , `index${ extension } ` ) ;
2828} ;
2929
30- const preparePackageJsonForTemplate = ( appPath , appName , isTypeScript ) => {
30+ const preparePackageJsonForTemplate = ( appPath , appName ) => {
3131 const dependencies = [
32- { name : 'sass' , version : '^1.34 .1' } ,
32+ { name : 'sass-embedded ' , version : '^1.85 .1' } ,
3333 { name : 'devextreme-cli' , version : latestVersions [ 'devextreme-cli' ] , dev : true } ,
3434 { name : 'react-router-dom' , version : '^6.3.0' } ,
3535 ] ;
@@ -61,26 +61,24 @@ const create = async(appName, options) => {
6161 isTypeScript : typescriptUtils . isTypeScript ( templateType )
6262 } ) ;
6363 const toolingVersion = extractToolingVersion ( options ) ;
64- const commandArguments = [ `-p=create-react-app ${ toolingVersion } ` , 'create-react-app ' , appName ] ;
64+ const commandArguments = [ `-p=create-vite ${ toolingVersion } ` , 'create-vite ' , appName ] ;
6565
66- const templateSuffix = templateOptions . isTypeScript ? '-typescript' : '' ;
67- const templatePath = path . resolve ( __dirname , `../templates/cra-template${ templateSuffix } ` ) ;
68-
69- commandArguments . push ( `--template file:${ templatePath } ` ) ;
66+ commandArguments . push ( `--template react${ templateOptions . isTypeScript ? '-ts' : '' } ` ) ;
7067
7168 await runCommand ( 'npx' , commandArguments ) ;
7269
7370 const appPath = path . join ( process . cwd ( ) , appName ) ;
7471
7572 modifyIndexHtml ( appPath , templateOptions . project ) ;
73+
7674 addTemplate ( appPath , appName , templateOptions ) ;
7775} ;
7876
7977const modifyIndexHtml = ( appPath , appName ) => {
80- const indexHtmlPath = path . join ( appPath , 'public' , ' index.html') ;
78+ const indexHtmlPath = path . join ( appPath , 'index.html' ) ;
8179
8280 let htmlContent = fs . readFileSync ( indexHtmlPath ) . toString ( ) ;
83- htmlContent = htmlContent . replace ( / < t i t l e > ( \w + \s * ) + < \/ t i t l e > / , `<title>${ appName } <\/title>` ) ;
81+ htmlContent = htmlContent . replace ( / < t i t l e > [ ^ < ] + < \/ t i t l e > / , `<title>${ appName } <\/title>` ) ;
8482 htmlContent = htmlContent . replace ( '<body>' , '<body class="dx-viewport">' ) ;
8583
8684 fs . writeFileSync ( indexHtmlPath , htmlContent ) ;
@@ -97,7 +95,6 @@ const addTemplate = (appPath, appName, templateOptions) => {
9795 ) ;
9896
9997 const manifestPath = path . join ( appPath , 'public' , 'manifest.json' ) ;
100- const indexPath = path . join ( appPath , 'src' , templateOptions . isTypeScript ? 'index.tsx' : 'index.js' ) ;
10198
10299 const styles = [
103100 './themes/generated/theme.additional.css' ,
@@ -108,15 +105,15 @@ const addTemplate = (appPath, appName, templateOptions) => {
108105 ] ;
109106
110107 templateCreator . moveTemplateFilesToProject ( applicationTemplatePath , appPath , templateOptions , getCorrectPath ) ;
111- removeFile ( path . join ( appPath , 'src' , 'App.css' ) ) ;
108+
112109 ! templateOptions . isTypeScript && removeFile ( path . join ( appPath , 'src' , 'types.js' ) ) ;
110+
113111 if ( ! templateOptions . empty ) {
114112 addSamplePages ( appPath , templateOptions ) ;
115113 }
116114
117115 preparePackageJsonForTemplate ( appPath , appName , templateOptions . isTypeScript ) ;
118116 updateJsonPropName ( manifestPath , appName ) ;
119- addPolyfills ( packageJsonUtils . getPackageJsonPath ( ) , indexPath ) ;
120117 install ( { } , appPath , styles ) ;
121118} ;
122119
@@ -130,15 +127,6 @@ const install = (options, appPath, styles) => {
130127 packageManager . runInstall ( { cwd : appPath } ) ;
131128} ;
132129
133- const addPolyfills = ( packagePath , indexPath ) => {
134- const packages = [
135- { name : 'react-app-polyfill' , version : '^1.0.0' }
136- ] ;
137-
138- packageJsonUtils . addDependencies ( packagePath , packages ) ;
139- moduleUtils . insertImport ( indexPath , './polyfills' ) ;
140- } ;
141-
142130const addStylesToApp = ( filePath , styles ) => {
143131 styles . forEach ( style => {
144132 moduleUtils . insertImport ( filePath , style ) ;
0 commit comments