Migration Guide
This guide will help you to migrate your WinnetouJs application from version 1 to version 2.
Changes
The main change is the configuration file. In version 1, the configuration file is a javascript file, now it is a JSON file.
The configuration file is now called win.config.json
and it is located in the root of your project.
Migration Guide: win.config.js
to win.config.json
This guide will help you migrate your WinnetouJs configuration file from a JavaScript-based win.config.js
to a JSON-based win.config.json
. The new format enhances compatibility, simplifies validation, and improves integration with other tools.
1. Understand the Differences
- JavaScript (
win.config.js
): Supports dynamic content through JavaScript logic (e.g., functions, imports). - JSON (
win.config.json
): A static configuration format using key-value pairs. All dynamic functionality must be resolved before migration.
2. Prepare Your win.config.js
for Conversion
Review your current win.config.js
to identify:
- JavaScript logic (e.g., computed values, imports).
- Default values or comments that may not directly translate to JSON.
// Example win.config.js
module.exports = {
serverPort: 3197,
constructosPath: './src/constructos',
constructosOut: './dist/constructos',
apps: [
{ entry: './src/app1/index.js', out: './dist/app1' },
{ entry: './src/app2/index.js', out: './dist/app2' }
],
sass: [
{
entryFolder: './src/styles',
outFolder: './dist/styles',
firstFile: './src/styles/_variables.scss' }
],
defaultLang: 'en-us',
publicPath: './public',
icons: './src/assets/icons'
};
3. Convert to JSON Format
Replace JavaScript-specific constructs with static values and create the win.config.json
file:
{
"$schema": "./node_modules/winnetoujs/schemas/win.config.schema.json",
"serverPort": 3197,
"constructosPath": "./src/constructos",
"constructosOut": "./dist/constructos",
"apps": [
{ "entry": "./src/app1/index.js", "out": "./dist/app1" },
{ "entry": "./src/app2/index.js", "out": "./dist/app2" }
],
"sass": [
{
"entryFolder": "./src/styles",
"outFolder": "./dist/styles",
"firstFile": "./src/styles/_variables.scss" }
],
"defaultLang": "en-us",
"publicPath": "./public",
"icons": "./src/assets/icons"
}
4. Update Your Codebase
Replace references to win.config.js
with win.config.json
:
// From:
const config = require('./win.config.js');
// To:
const config = require('./win.config.json');
5. Validate the Configuration
- Use a JSON linter or schema validator to ensure the JSON is correctly formatted.
- Run your project to verify that the configuration is correctly applied.
6. Test Thoroughly
Validate all features dependent on configuration (e.g., apps, Sass paths, icons) to ensure no regressions are introduced.
7. Deprecate win.config.js
After successful migration, remove the old win.config.js
file to avoid confusion and accidental usage.
8. Benefits of Using JSON
- Portability: Easier to share and integrate with external tools.
- Validation: Simplified schema validation using JSON Schema.
- Readability: Cleaner format for static configurations.
By following this guide, you can seamlessly transition to the new win.config.json
format and take advantage of its benefits.
Troubleshooting
node wbr --run-server for vscode extension issues
Update your socket.io to 4.8.1+ in order to fix WinnetouJs Extension Server errors.