Skip to content

Bruk postcss-bundler til å scope css til dekorator #548

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

Merged
merged 2 commits into from
Mar 6, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/main-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Upload build
uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch'
with:
name: app-dist
path: dist
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
src/index.bundled.css

# Logs
logs
*.log
Expand Down
133 changes: 118 additions & 15 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ export default tseslint.config(
extends: [tseslint.configs.disableTypeChecked],
},
prettier,
{
ignores: ['*.cjs'],
},
);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
}
},
"scripts": {
"gen-css": "bunx postcss-cli src/index.css > src/index.bundled.css",
"dev-server": "bun run --watch dev-server/index.ts",
"dev": "vite",
"dev:fullscreen": "VITE_DECORATOR_MODE=fullscreen vite",
"build": "vite build",
"build": "bun run gen-css && vite build",
"build:watch": "vite build --watch",
"build-and-preview": "vite build && vite preview",
"preview": "vite preview",
Expand All @@ -30,8 +31,10 @@
"format": "prettier . --write"
},
"devDependencies": {
"@csstools/postcss-bundler": "^2.0.6",
"@eslint/js": "^9.21.0",
"@tailwindcss/vite": "^4.0.9",
"@tailwindcss/postcss": "^4.0.5",
"@types/bun": "^1.2.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
Expand All @@ -43,6 +46,7 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"msw": "^2.7.0",
"postcss-cli": "^11.0.0",
"prettier": "^3.5.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
'@tailwindcss/postcss': {},
'@csstools/postcss-bundler': {},
},
};
2 changes: 1 addition & 1 deletion src/Decorator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PropsWithChildren, useMemo } from 'react';
import './index.css';
import './index.bundled.css';
import useAppLogic from './hooks/useAppLogic';
import Banner from './components/Banner';
import Menu from './components/Menu';
Expand Down
2 changes: 1 addition & 1 deletion src/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import './index.css';
import './index.bundled.css';
import classNames from 'classnames';
import useAppLogic from './hooks/useAppLogic';
import { AppProps } from './types/AppProps';
Expand Down
3 changes: 2 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import url('node_modules:@navikt/ds-css') scope(.dekorator);
@import '@navikt/ds-css/dist/global/tokens.css';
@import 'tailwindcss' prefix(dr);
@import '@navikt/ds-css' layer(dr-aksel);

@config '../tailwind.config.js';

Expand Down
1 change: 1 addition & 0 deletions src/wrapper/FullScreenWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import '@navikt/ds-css';
import LandingPage from '../LandingPage';

const FullScreenWrapper = () => {
Expand Down
1 change: 1 addition & 0 deletions src/wrapper/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Button, TextField } from '@navikt/ds-react';
import '@navikt/ds-css';
import { useTempValue } from './hooks/useTempValue';
import { WebSocketWrapper } from '../api/WebSocketWrapper';
import { ContextHolderAPI } from '../api/ContextHolderAPI';
Expand Down
3 changes: 1 addition & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

export default defineConfig({
plugins: [react(), tailwindcss()],
plugins: [react()],
build: {
minify: true,
manifest: 'asset-manifest.json',
Expand Down