Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cra to vite create play service update #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ function %PLAY_TITLE_NAME_SANITIZED%(props) {
);
}

export default %PLAY_TITLE_NAME_SANITIZED%;
export default %PLAY_TITLE_NAME_SANITIZED%;
12 changes: 6 additions & 6 deletions lib/services/template/play_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TEMPLATE_DIRECTORY = "_templates";

const TEMPLATE_MAP = {
common: ["Readme_md"],
js: ["component_js"],
js: ["component_jsx"],
ts: ["component_tsx"],
css: ["styles_css"],
scss: ["styles_scss"],
Expand Down Expand Up @@ -59,16 +59,16 @@ const replaceTemplateVar = (play_data, filePath) => {
};

const getTargetFileName = (source_file_name) => {
// e.g: component_js.tmpl
const source_file_name_ext_index = source_file_name.lastIndexOf("."); // ['component_js','tmpl']
// e.g: component_jsx.tmpl
const source_file_name_ext_index = source_file_name.lastIndexOf("."); // ['component_jsx','tmpl']
const file_name_wo_ext = source_file_name.substring(
0,
source_file_name_ext_index
); // 'component_js'
); // 'component_jsx'

const source_file_name_segment = file_name_wo_ext.split("_"); // ['component', 'js']
const source_file_name_segment = file_name_wo_ext.split("_"); // ['component', 'jsx']
const new_file_ext =
source_file_name_segment[source_file_name_segment.length - 1]; // 'js'
source_file_name_segment[source_file_name_segment.length - 1]; // 'jsx'
source_file_name_segment.splice(-1, 1); // ['component']
const new_file_name_wo_ext = source_file_name_segment.join(""); // 'component'

Expand Down