Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vite): introduce @linaria/vite (#1118)
* refactor(rollup): make rollup standalone * feat(vite): add vite plugin * feat(vite): add astro-solid example * fix(vite): remove commented 'enforce' parameter * chore(typings): switch to ESNext * fix(vite): remove watch flag from build * chore: change esnext to array of exact features * feat(vite): fix virtual vss import path * feat(vite): fix vite example and lockfile * fix(rollup): deprecate Vite support * chore: fix changelog for rollup * chore: linter & pnpm-lock Co-authored-by: Anton Evzhakov <anton@evz.name>
- Loading branch information
Showing
22 changed files
with
2,724 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@linaria/rollup': minor | ||
--- | ||
|
||
Make rollup standalone. The support for Vite in @linaria/rollup is deprecated and will be removed in the next major version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@linaria/vite': major | ||
--- | ||
|
||
Add Vite plugin with HMR support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import astro_solid from '@astrojs/solid-js'; | ||
import vite_linaria from '@linaria/vite'; | ||
import vite_inspect from 'vite-plugin-inspect'; | ||
|
||
export default defineConfig({ | ||
output: 'static', | ||
srcDir: '.', | ||
root: '.', | ||
integrations: [astro_solid()], | ||
server: { | ||
host: '0.0.0.0', | ||
port: 3000, | ||
}, | ||
build: { | ||
format: 'file', | ||
}, | ||
vite: { | ||
plugins: [ | ||
vite_linaria({ | ||
displayName: true, | ||
classNameSlug: (hash, title, args) => `${args.dir}_${title}_${hash}`, | ||
babelOptions: { | ||
presets: ['solid'], | ||
}, | ||
}), | ||
vite_inspect(), | ||
], | ||
css: { | ||
modules: false, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "astro-solid-example", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"type": "module", | ||
"devDependencies": { | ||
"@astrojs/solid-js": "^1.2.3", | ||
"@babel/core": "^7.18.6", | ||
"@linaria/core": "workspace:^", | ||
"@linaria/shaker": "workspace:^", | ||
"@linaria/vite": "workspace:^", | ||
"astro": "^1.6.10", | ||
"solid-js": "^1.6.2", | ||
"vite": "^3.2.4", | ||
"vite-plugin-inspect": "^0.7.8" | ||
}, | ||
"scripts": { | ||
"dev": "astro dev --force", | ||
"build": "astro build" | ||
}, | ||
"author": "Dmitriy Nikiforov" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { css } from '@linaria/core'; | ||
import { CSRChild, cssVariableFromModule } from './csr_child'; | ||
import { astroTextColor } from './external'; | ||
|
||
// Try to change some variables white in dev mode | ||
const GLOBAL_VARS = { | ||
color_header: 'red', | ||
} as const; | ||
|
||
export default function CSRComponent() { | ||
const LOCAL_VARS = { | ||
description_font_style: 'bold', | ||
} as const; | ||
return ( | ||
<div> | ||
<h1> | ||
Hello! This is{' '} | ||
<strong | ||
class={css` | ||
color: ${GLOBAL_VARS.color_header}; | ||
`} | ||
> | ||
Solid | ||
</strong>{' '} | ||
app built with{' '} | ||
<strong | ||
class={css` | ||
color: palevioletred; | ||
`} | ||
> | ||
Linaria | ||
</strong>{' '} | ||
powered by | ||
<br /> | ||
<strong | ||
class={css` | ||
color: ${astroTextColor}; | ||
font-size: ${cssVariableFromModule}; | ||
`} | ||
> | ||
Astro | ||
</strong> | ||
</h1> | ||
<div | ||
class={css` | ||
font-style: ${LOCAL_VARS.description_font_style}; | ||
`} | ||
> | ||
This component was rendered on client. | ||
</div> | ||
<CSRChild /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { css } from '@linaria/core'; | ||
import { astroTextColor } from './external'; | ||
|
||
export function CSRChild() { | ||
return ( | ||
<div | ||
class={css` | ||
float: right; | ||
color: ${astroTextColor}; | ||
`} | ||
> | ||
I am child module! | ||
</div> | ||
); | ||
} | ||
// Try to change some variables white in dev mode | ||
export const cssVariableFromModule = '64px'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const astroTextColor = 'orange'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
import CSRComponent from './csr'; | ||
--- | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Linaria – zero-runtime CSS in JS library</title> | ||
</head> | ||
|
||
<CSRComponent client:only="solid-js" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"module": "ESNext", | ||
"target": "ESNext", | ||
"jsx": "preserve", | ||
"jsxImportSource": "solid-js", | ||
"moduleResolution": "Node" | ||
}, | ||
"exclude": ["node_modules"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { "paths": {}, "rootDir": "src/", "types": ["node"] }, | ||
"compilerOptions": { "paths": {}, "rootDir": "src/" }, | ||
"references": [{ "path": "../babel" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.