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

new-log-viewer: Ensure all static assets are copied from /public to /dist during the build process (fixes #95). #96

Merged
merged 5 commits into from
Oct 19, 2024

Conversation

junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Oct 17, 2024

References

Fixes #95
new-log-viewer series: #45 #46 #48 #51 #52 #53 #54 #55 #56 #59 #60 #61 #62 #63 #66 #67 #68 #69 #70 #71 #72 #73 #74 #76 #77 #78 #79 #80 #81 #82 #83 #84 #89 #91 #93 #94

Description

  1. Copy all static assets from /public to /dist during the build process.

Validation performed

  1. Repeated the reproduction steps in issue new-log-viewer: Favicon not included in built assets. #95 .
  2. Found the favicon.svg generated in /dist and in the built log viewer the YSscope icon was displayed correctly.

Summary by CodeRabbit

  • New Features
    • Added a favicon to enhance the application's appearance in browser tabs.
    • Improved management of static assets through the addition of a file copying feature in the build process.
    • Enhanced organization of file paths for better handling of static assets in the build process.

Copy link

coderabbitai bot commented Oct 17, 2024

Walkthrough

The changes involve updating the package.json file to include a new development dependency, copy-webpack-plugin, and modifying the webpack.common.js configuration. The updates in webpack.common.js include the addition of the CopyWebpackPlugin to manage static assets, the introduction of new variables for output paths, and the configuration of the plugin to copy files from the public directory while ignoring the index.html file.

Changes

File Change Summary
new-log-viewer/package.json Added copy-webpack-plugin dependency in devDependencies.
new-log-viewer/webpack.common.js Added CopyWebpackPlugin, defined new path variables, and updated output paths.

Assessment against linked issues

Objective Addressed Explanation
Favicon not included in built assets (#95) The changes do not address the inclusion of the favicon in the built assets.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ae24669 and aa956d2.

📒 Files selected for processing (1)
  • new-log-viewer/webpack.common.js (1 hunks)
🧰 Additional context used

new-log-viewer/webpack.common.js Outdated Show resolved Hide resolved
@junhaoliao junhaoliao requested a review from Henry8192 October 18, 2024 00:59
@junhaoliao junhaoliao changed the title Add favicon to HtmlWebpackPlugin configuration. new-log-viewer: Copy all static assets from /public to /dist during the build process. Oct 18, 2024
@junhaoliao junhaoliao changed the title new-log-viewer: Copy all static assets from /public to /dist during the build process. new-log-viewer: Copy all static assets from /public to /dist during the build process (fixes #95). Oct 18, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
new-log-viewer/package.json (1)

49-49: LGTM! Consider pinning the dependency version.

The addition of copy-webpack-plugin as a dev dependency is appropriate for addressing the favicon issue mentioned in the PR objectives. This plugin will likely be used in the Webpack configuration to copy the favicon to the build output directory.

Consider pinning the exact version of copy-webpack-plugin to ensure consistent builds across different environments. You can do this by removing the caret:

-    "copy-webpack-plugin": "^12.0.2",
+    "copy-webpack-plugin": "12.0.2",

This change would prevent potential issues arising from minor updates to the plugin.

new-log-viewer/webpack.common.js (1)

70-83: Well-configured CopyWebpackPlugin with a minor suggestion.

The CopyWebpackPlugin configuration effectively manages static assets, correctly ignoring the index.html file. The Windows path compatibility handling is a nice touch.

Consider adding a comment explaining why index.html is ignored, to improve code maintainability:

ignore: [
    // Ignore index.html as it's handled by HtmlWebpackPlugin
    indexHtmlPath.replaceAll("\\", "/"),
],
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aa956d2 and 4a39a96.

⛔ Files ignored due to path filters (1)
  • new-log-viewer/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • new-log-viewer/package.json (1 hunks)
  • new-log-viewer/webpack.common.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (5)
new-log-viewer/webpack.common.js (5)

5-5: LGTM! CopyWebpackPlugin addition is appropriate.

The addition of CopyWebpackPlugin aligns with the PR objectives and is a good practice for managing static assets in webpack configurations.


10-12: Excellent addition of path variables.

The introduction of distPath, publicPath, and indexHtmlPath variables enhances code readability and maintainability. Centralizing these paths makes future updates easier and ensures cross-platform compatibility through the use of path.resolve.


64-64: Good use of the new distPath variable.

Updating the output path to use the distPath variable maintains consistency with the newly defined variables and simplifies the configuration.


85-85: Good update to HtmlWebpackPlugin configuration.

Using the indexHtmlPath variable for the template path in HtmlWebpackPlugin configuration maintains consistency and simplifies the overall webpack setup.


Line range hint 5-85: Overall excellent webpack configuration updates.

These changes effectively address the PR objectives by:

  1. Centralizing path definitions for improved maintainability.
  2. Properly configuring CopyWebpackPlugin to manage static assets.
  3. Updating HtmlWebpackPlugin to use the new path variables.

These modifications should resolve the favicon issue and improve the overall build process for the YScope log viewer.

To verify the changes:

from: publicPath,
globOptions: {
ignore: [
// The `replaceAll()` is needed because the plugin does not convert
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The `replaceAll()` is needed because the plugin does not convert
// Below `replaceAll()` is needed because the plugin does not convert

Copy link
Collaborator

@Henry8192 Henry8192 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
For the title, how about
new-log-viewer: Ensure all static assets from /public to /dist are copied during the build process (fixes #95).

@junhaoliao junhaoliao changed the title new-log-viewer: Copy all static assets from /public to /dist during the build process (fixes #95). new-log-viewer: Ensure all static assets from /public are copied to /dist during the build process (fixes #95). Oct 19, 2024
@junhaoliao junhaoliao changed the title new-log-viewer: Ensure all static assets from /public are copied to /dist during the build process (fixes #95). new-log-viewer: Ensure all static assets are copied from /public to /dist during the build process (fixes #95). Oct 19, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
new-log-viewer/webpack.common.js (2)

10-12: LGTM! Path variables improve organization.

The addition of distPath, publicPath, and indexHtmlPath variables enhances code organization and maintainability. These centralized path definitions will make future updates easier and ensure cross-platform compatibility.

For consistency, consider using __dirname in all path definitions:

-const distPath = path.resolve(__dirname, "dist");
-const publicPath = path.resolve(__dirname, "public");
+const distPath = path.resolve(__dirname, "dist");
+const publicPath = path.resolve(__dirname, "public");
 const indexHtmlPath = path.resolve(publicPath, "index.html");

70-83: LGTM! CopyWebpackPlugin configuration is well-structured.

The CopyWebpackPlugin configuration effectively copies static assets from /public to /dist, aligning with the PR objective. The ignore pattern for index.html is appropriate, as it's handled separately by HtmlWebpackPlugin.

The use of replaceAll() to handle Windows paths is a good practice. For clarity, consider adding a comment explaining why this is necessary:

 // `replaceAll()` is needed because the plugin does not convert Windows
 // paths to POSIX paths for `ignore` patterns.
-indexHtmlPath.replaceAll("\\", "/"),
+indexHtmlPath.replaceAll("\\", "/"), // Convert Windows backslashes to forward slashes
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6d196a3 and 357445f.

📒 Files selected for processing (1)
  • new-log-viewer/webpack.common.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (4)
new-log-viewer/webpack.common.js (4)

5-5: LGTM! CopyWebpackPlugin addition is appropriate.

The addition of CopyWebpackPlugin aligns with the PR objective of copying static assets from /public to /dist during the build process. This is a suitable choice for managing static assets in webpack configurations.


64-64: LGTM! Output path update is consistent.

The update to use distPath for the output path is consistent with the newly defined variables and improves code maintainability.


85-85: LGTM! HtmlWebpackPlugin template path update is consistent.

The update to use indexHtmlPath for the HtmlWebpackPlugin template path is consistent with the newly defined variables and improves code maintainability.


Line range hint 1-161: Overall, excellent implementation of static asset management.

The changes effectively address the PR objective of copying static assets from /public to /dist during the build process. The implementation is well-structured, maintainable, and consistent. The use of centralized path variables and appropriate webpack plugins demonstrates good coding practices.

To verify the implementation, you can run the following script:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new-log-viewer: Favicon not included in built assets.
2 participants