Skip to content

Commit b704221

Browse files
committed
#171 basic web component
1 parent 09c552d commit b704221

14 files changed

Lines changed: 1659 additions & 64 deletions

babel.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import path from 'path'
2+
import { fileURLToPath } from 'url'
3+
import { resolvePathsUsingDecorators, litDecoratorsBabelOptions } from './config/babel.mjs'
4+
5+
const projectRoot = path.dirname(fileURLToPath(import.meta.url))
6+
const pathsUsingDecorators = resolvePathsUsingDecorators(projectRoot)
7+
18
export default {
29
presets: [
310
'@babel/preset-typescript',
@@ -18,5 +25,11 @@ export default {
1825
]
1926
}
2027
]
28+
],
29+
overrides: [
30+
{
31+
include: pathsUsingDecorators,
32+
...litDecoratorsBabelOptions,
33+
}
2134
]
2235
}

config/babel.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import path from 'path'
2+
3+
/**
4+
* This file contains config options for babel using Lit decorators.
5+
*
6+
* @see https://lit.dev/docs/components/decorators/#using-decorators-with-babel
7+
*/
8+
9+
const pathsUsingDecorators = ['src/design-system', 'src/primitives', 'src/storybook', 'src/components']
10+
11+
export const litDecoratorsBabelOptions = {
12+
assumptions: {
13+
setPublicClassFields: false
14+
},
15+
plugins: [
16+
'@babel/plugin-transform-class-static-block',
17+
['@babel/plugin-transform-typescript', { allowDeclareFields: true }],
18+
['@babel/plugin-proposal-decorators', { version: '2023-05' }],
19+
['@babel/plugin-transform-class-properties', { loose: true }]
20+
]
21+
}
22+
23+
export const litDecoratorsLoaderOptions = {
24+
cacheDirectory: true,
25+
...litDecoratorsBabelOptions,
26+
}
27+
28+
export function resolvePathsUsingDecorators (projectRoot) {
29+
return pathsUsingDecorators.map((_path) => path.resolve(projectRoot, _path))
30+
}

config/postcss.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import PostCSS from 'postcss'
2+
import TailwindCSS from '@tailwindcss/postcss'
3+
4+
const cssProcessor = PostCSS([TailwindCSS()])
5+
6+
export default {
7+
async transform (css, { filePath }) {
8+
const result = await cssProcessor.process(css, { from: filePath })
9+
10+
return result.css
11+
}
12+
}

declarations.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
declare module '*.styles.css' {
2+
import type { CSSResultGroup } from 'lit'
3+
const styles: CSSResultGroup
4+
export default styles
5+
}
6+
17
declare module '*.css';

0 commit comments

Comments
 (0)