@oreodusk/oreonyx
v1.2.0
Published
Module bundler and code compilation helper. Provide webpack configurations for SSR and CSR applications.
Maintainers
Readme
oreonyx
A module bundler and code compilation helper for React and vanilla JavaScript
oreonyx is a simplified module bundler and code compilation helper that streamlines JavaScript bundling for both client-side rendering (CSR) and server-side rendering (SSR) applications. It provides an abstraction layer over webpack, eliminating the need for manual configuration.
Features
- ✨ Zero webpack configuration required
- ⚛️ React and vanilla JavaScript support
- 🔄 Client-side and server-side rendering
- 🚀 Built-in development server
- 📦 Automatic asset bundling
- 🎯 Simple API interface
Installation
npm install @oreodusk/oreonyx --save-devor
yarn add @oreodusk/oreonyx -DQuick Start
Prerequisites
Before using oreonyx, create the following files in your project root directory:
nyx.browser.js(required for CSR)nyx.server.js(optional, only needed for SSR)template.html(required)
Basic Setup
Client-Side Rendering (CSR)
Create a nyx.browser.js file:
const { BrowserApi } = require("@oreodusk/oreonyx");
module.exports = BrowserApi
.entry("./view/js/browser.js")
.setHost("http://localhost:5050")
.setMode("development")
.run();Server-Side Rendering (SSR)
Create a nyx.server.js file:
const { ServerApi } = require("@oreodusk/oreonyx");
module.exports = ServerApi
.entry("./view/js/server.js")
.setHost("http://localhost:5050")
.setMode("development")
.run();API Reference
BrowserApi
The BrowserApi handles client-side bundling and provides options for controlling the output markup.
Basic Usage
const { BrowserApi } = require("@oreodusk/oreonyx");
module.exports = BrowserApi
.entry("./view/js/browser.js")
.setHost("http://localhost:5050")
.setMode("development")
.run();Advanced Configuration
You can customize the markup generation and enable the development server:
const { BrowserApi } = require("@oreodusk/oreonyx");
const props = {
markUpControl: {
ext: "html", // Options: 'html' or 'php'
dir: "dist", // Options: 'self' or 'dist'
},
devServer: true, // Enable development server
};
module.exports = BrowserApi
.entry("./view/js/browser.js")
.setHost("http://localhost:5050")
.setMode("development")
.run(props);Configuration Options
| Property | Type | Default | Description |
| ------------------- | --------- | ------- | -------------------------------------------------------------------------- |
| markUpControl.ext | string | php | Output file extension (html or php) |
| markUpControl.dir | string | self | Output directory (self for entry directory, dist for public directory) |
| devServer | boolean | false | Enable development server |
Note: By default, oreonyx generates markup with a .php extension in the current/entry directory.
ServerApi
The ServerApi handles server-side bundling for SSR applications.
const { ServerApi } = require("@oreodusk/oreonyx");
module.exports = ServerApi
.entry("./view/js/server.js")
.setHost("http://localhost:5050")
.setMode("development")
.run();CLI Commands
oreonyx includes a command-line tool called nyx for convenient bundling operations.
Setup
Add the following scripts to your app's package.json:
{
"scripts": {
"build:dev": "nyx build dev",
"build:ssr": "nyx ssr dev",
"build:csr": "nyx csr dev",
"serve": "nyx csr dev --serve",
"build:ssr:watch": "nyx ssr dev --watch",
"build:csr:watch": "nyx csr dev --watch",
"build:prod": "nyx build prod"
}
}Available Commands
| Command | Description |
| ------------------------- | ------------------------------------------------ |
| npm run build:dev | Bundle both CSR and SSR code in development mode |
| npm run build:ssr | Bundle only SSR code in development mode |
| npm run build:csr | Bundle only CSR code in development mode |
| npm run serve | Bundle CSR code and start development server |
| npm run build:ssr:watch | Bundle SSR code in watch mode (development) |
| npm run build:csr:watch | Bundle CSR code in watch mode (development) |
| npm run build:prod | Bundle both CSR and SSR code in production mode |
Project Structure Example
your-project/
├── view/
│ └── js/
│ ├── browser.js
│ └── server.js
├── public/
├── nyx.browser.js
├── nyx.server.js
├── template.html
└── package.jsonDevelopment Workflow
For CSR Only
- Create
nyx.browser.jsandtemplate.html - Run
npm run servefor development with hot reload - Run
npm run build:prodfor production build
For SSR
- Create both
nyx.browser.jsandnyx.server.js - Create
template.html - Run
npm run build:devfor development - Run
npm run build:prodfor production build
Watch Mode
Use watch mode during development for automatic rebuilding:
# For CSR
npm run build:csr:watch
# For SSR
npm run build:ssr:watchModes
oreonyx supports two bundling modes:
development: Unminified code with source maps for debuggingproduction: Minified and optimized code for deployment
Contributing
We welcome contributions to oreonyx! Here's how you can help:
Reporting Issues
- Check if the issue already exists in the Issues section
- Provide a clear description of the problem
- Include steps to reproduce the issue
- Share your environment details (Node version, OS, etc.)
Submitting Pull Requests
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name) - Make your changes
- Test your changes thoroughly
- Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature-name) - Open a Pull Request
Development Setup
# Create projects directory
mkdir ~/projects
# Go to projects directory
cd ~/projects
# Clone the repository
git clone https://github.com/toerso/oreonyx.git
# Go to projects/oreonyx library directory
cd ~/projects/oreonyx
# Install dependencies
npm install
# Link oreonyx globally(Create a symlink)
npm link
# In your application project
cd ~/projects/my-app
npm link @oreodusk/oreonyx
Code Style
- Follow the existing code style
- Write clear, descriptive commit messages
- Add comments for complex logic
- Update documentation as needed
Support
Getting Help
- Documentation: Check this README for usage instructions
- Issues: Open an issue for bugs or feature requests
- Discussions: Use Discussions for questions and ideas
Frequently Asked Questions
Q: Do I need both nyx.browser.js and nyx.server.js?
A: Only if you're using SSR. For CSR-only projects, you just need nyx.browser.js.
Q: What Node.js version is required?
A: Node.js 12.x or higher is recommended.
Q: Can I use this with TypeScript?
A: Currently, oreonyx is designed for JavaScript projects. TypeScript support may be added in future versions.
Community
- Star ⭐ this repository if you find it helpful
- Share your projects built with oreonyx
- Spread the word!
License
MIT © oreodusk
Made with ❤️ for the JavaScript community by Topu/Toerso
