How miwashutaro0611/front-base works
Project Overview and Purpose
• This is a front-end development environment built around generating non-SPA pages. It uses Pug for templating, Dart-sass (SCSS) for styling, and TypeScript for JavaScript, with a build process powered by webpack. The project also includes automated testing (Jest), linting, CI/CD configurations (CircleCI, GitHub Actions), Docker deployment support, and image processing scripts.
Main Components
a. Source Code and Assets:
• Templates: Located in src/pug – where Pug templates are maintained. Sub-directories like _data, _mixin, _modules, and _templates indicate modular template components.
• Styles: Found in src/assets/scss – using a structured approach with foundation, layouts, objects, and utilities (variables and mixins).
• Scripts/Modules: In src/assets/js – with common scripts, modules (alert, barba, etc.), and utilities (device checks, WebP support).
• Media Assets: Images, fonts, and other static assets are in src/assets/img, fonts, and static directories.
• Content: The src/posts folder (even though it appears empty) can be considered as a placeholder for content.
b. Build System:
• Webpack Configuration: Multiple webpack configuration files (webpack.common.js, webpack.dev.js, webpack.prod.js, and additional ones like webpack.pages.js, webpack.htmlinjector.js) indicate separate concerns for development, build optimizations, and HTML injection.
• TypeScript and Babel: tsconfig.json and .babelrc for JavaScript/TypeScript compilation.
• Bundling and Testing: Jest configuration (jest.config.js) and linting with ESLint, Prettier, and stylelint (stylelint.config.js).
c. Automation, Testing, and Deployment:
• Automated Scripts: Under the script folder, automated image processing (squoosh-min.mjs and squoosh-webp-avif.mjs) for image compression and format conversion.
• Testing: The spec directory contains TypeScript test specs (e.g. alert.spec.ts, device.spec.ts).
• Deployment/Environment: Dockerfile, docker-compose.yml, netlify.toml provide deployment details. Additionally, CI/CD setups with CircleCI (.circleci/config.yml) and GitHub Actions (in the .github folder) are present.
• Other configurations: Files for commit linting (commitlint.config.js, .husky hooks), editor configurations (.editorconfig), and ESLint/Prettier settings.
Relationships and Data Flow
– Webpack transformations may involve tasks such as HTML injection (with webpack.htmlinjector.js) and page-level bundling (webpack.pages.js).
– Image processing scripts are invoked during asset preparation, likely as a pre-build step or as part of the build process.
– Linting and testing (Jest-based unit tests in spec) occur simultaneously to ensure code quality. These components influence and sometimes integrate with the CI/CD pipeline (GitHub Actions and CircleCI).
– Deployment components (Dockerfile, docker-compose.yml, netlify.toml) indicate that upon a successful build, the output is containerized or deployed to platforms like Netlify.
Architectural Patterns or Design Principles
– The project is modular: Each asset type (templates, styles, scripts) is organized into its own directory, emphasizing separation of concerns.
– The build system’s multiple webpack configurations highlight environment-specific optimizations and a clear build separation between development and production.
– The presence of CI/CD and deployment files indicates a DevOps-oriented approach rather than a monolithic build-and-deploy process.
– There is an emphasis on extensibility with image optimization scripts and upgradeable libraries, suggesting a focus on modern front-end practices.