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

[VO-1195] chore: Migrate to Rsbuild #450

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
"node": "~16 || ~20"
},
"scripts": {
"analyze": "COZY_SCRIPTS_ANALYZER=true yarn build",
"analyze": "RSDOCTOR=true yarn build",
"lint": "yarn lint:js && yarn lint:styles",
"lint:js": "cs lint '{src,test}/**/*.{js,jsx,ts,tsx}'",
"lint:styles": "stylint src/styles --config ./.stylintrc",
"prebuild": "yarn lint",
"build": "cs build --browser --barV7 false",
"watch": "cs watch --browser --barV7 false",
"start": "cs start --browser --barV7 false",
"build": "rsbuild build",
"watch": "rsbuild build --watch",
"deploy": "git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build} --repo=${DEPLOY_REPOSITORY:-https://[email protected]/cozy/coachCO2.git}",
"test": "env NODE_ENV=test cs test --verbose --coverage",
"cozyPublish": "cozy-app-publish --token $REGISTRY_TOKEN --prepublish downcloud --postpublish mattermost --space larochelle",
Expand Down Expand Up @@ -46,6 +44,7 @@
"@testing-library/react-hooks": "8.0.1",
"@typescript-eslint/eslint-plugin": "6.4.1",
"@typescript-eslint/parser": "6.4.1",
"@rsbuild/core": "1.1.2",
"argparse": "^2.0.1",
"babel-preset-cozy-app": "^2.1.0",
"bundlemon": "3.1.0",
Expand All @@ -67,7 +66,8 @@
"react-hot-loader": "4.13.0",
"react-test-renderer": "18.2.0",
"terser-webpack-plugin": "1.4.4",
"typescript": "4.9.5"
"typescript": "4.9.5",
"rsbuild-config-cozy-app": "file:/Users/cballevre/Documents/Lab/cozy-libs/config/rsbuild-config-cozy-app/rsbuild-config-cozy-app-v0.0.3.tgz"
},
"dependencies": {
"@react-pdf/renderer": "3.1.12",
Expand Down
File renamed without changes
File renamed without changes.
9 changes: 9 additions & 0 deletions rsbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const rsbuild = require('@rsbuild/core')
const configCozyApp = require('rsbuild-config-cozy-app')

const config = configCozyApp.getRsbuildConfig({
title: 'Coach CO2',
hasServices: true
})

export default rsbuild.defineConfig(config)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@require 'settings/breakpoints.styl'
// @require 'settings/breakpoints.styl'

.CertificateGeneration-root
background-color var(--paperBackgroundColor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import BikeGoalChart from 'src/components/Goals/BikeGoal/BikeGoalChart'
import styles from 'src/components/Goals/BikeGoal/Certificate/CertificateGeneration.styl'
import styles from 'src/components/Goals/BikeGoal/Certificate/CertificateGeneration.module.styl'
import { PDFCertificate } from 'src/components/Goals/BikeGoal/Certificate/PDFCertificate/PDFCertificate'
import { savePdfCertificate } from 'src/components/Goals/BikeGoal/Certificate/helpers'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Trip/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import L from 'leaflet'
import styles from 'src/components/Trip/tripmap.styl'
import styles from 'src/components/Trip/tripmap.module.styl'

export const MAP_PADDING = 16

Expand Down
28 changes: 9 additions & 19 deletions src/targets/browser/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,19 @@
<html lang="{{.Locale}}">
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#297EF2">
<% if (__STACK_ASSETS__) { %>
{{.CozyFonts}}
<% } else { %>
<link rel="stylesheet" type="text/css" href="//{{.Domain}}/assets/fonts/fonts.css">
<% } %>
<meta name="theme-color" content="#ffffff">
<title><%= htmlPlugin.options.title %></title>
<link rel="apple-touch-icon" sizes="180x180" href="/public/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/public/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/public/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/public/manifest.json" crossorigin="use-credentials">
<link rel="mask-icon" href="/public/safari-pinned-tab.svg" color="#297EF2">
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, viewport-fit=cover">
<% _.forEach(htmlWebpackPlugin.files.css, function(file) { %>
<link rel="stylesheet" href="<%- file %>">
<% }); %>
<link rel="stylesheet" type="text/css" href="//{{.Domain}}/assets/fonts/fonts.css">
{{.ThemeCSS}}
</head>
<div
role="application"
data-cozy="{{.CozyData}}"
>
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>
<script src="<%- file %>"></script>
<% }); %>
></div>
2 changes: 1 addition & 1 deletion src/targets/browser/setupApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const setupApp = memoize(() => {
const container = document.querySelector('[role=application]')
const root = createRoot(container)
const { lang } = getValues(JSON.parse(container.dataset.cozy))
const polyglot = initTranslation(lang, lang => require(`locales/${lang}`))
const polyglot = initTranslation(lang, lang => require(`src/locales/${lang}`))
const client = getClient()
client.registerPlugin(flag.plugin)
client.registerPlugin(RealtimePlugin)
Expand Down
Empty file removed src/targets/intents/.gitkeep
Empty file.
2 changes: 0 additions & 2 deletions src/targets/mobile/DOCS.md

This file was deleted.

Empty file removed src/targets/mobile/config.xml
Empty file.
13 changes: 1 addition & 12 deletions src/utils/bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import manifest from '../../manifest.webapp'

const getDataOrDefault = (data, defaultData) => {
return /^\{\{\..*\}\}$/.test(data) ? defaultData : data
}
Expand All @@ -8,21 +6,12 @@ const getDataOrDefault = (data, defaultData) => {
* default data will allow to display correctly the cozy-bar
* in the standalone (without cozy-stack connexion)
*/
export const getValues = ({ app, locale }) => {
export const getValues = ({ locale }) => {
const defaultValues = {
appIconDefault: require('src/targets/vendor/assets/icon.svg'),
appNamePrefixDefault: manifest.name_prefix,
appNameDefault: manifest.name,
appLocaleDefault: 'en'
}

return {
appName: getDataOrDefault(app.name, defaultValues.appNameDefault),
appNamePrefix: getDataOrDefault(
app.prefix,
defaultValues.appNamePrefixDefault
),
iconPath: getDataOrDefault(app.icon, defaultValues.appIconDefault),
lang: getDataOrDefault(locale, defaultValues.appLocaleDefault)
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["./src/**/*"],
"include": ["./src/**/*", "public/service-worker.js"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
Expand Down
Loading
Loading