File tree Expand file tree Collapse file tree 4 files changed +12
-12
lines changed
Expand file tree Collapse file tree 4 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 11import { defineBuildConfig } from 'unbuild'
22
33export default defineBuildConfig ( {
4- // TODO: fix issue in unbuild with inlining package.json
5- // `Inlined implicit external D:\a\color-mode\color-mode\package.json`
6- failOnWarn : false ,
7- entries : [ 'src/script' ] ,
84 hooks : {
95 'rollup:options' ( _ctx , options ) {
106 options . treeshake = false
Original file line number Diff line number Diff line change 2727 " dist"
2828 ],
2929 "scripts" : {
30- "prepack" : " nuxt-module-build build && esbuild --minify dist /script.mjs --outfile=dist/script.min.js" ,
30+ "prepack" : " nuxt-module-build build && esbuild --minify src /script.js --outfile=dist/script.min.js" ,
3131 "build" : " pnpm run prepack" ,
3232 "dev" : " nuxi dev playground" ,
3333 "dev:build" : " nuxi build playground" ,
Original file line number Diff line number Diff line change 1+ // @ts -check
2+
13// Add dark / light detection that runs before loading Nuxt
24( ( ) => {
35 // Global variable minimizers
1618
1719 addColorScheme ( value )
1820
19- // @ts -ignore
21+
2022 w [ '<%= options.globalName %>' ] = {
2123 preference,
2224 value,
2527 removeColorScheme
2628 }
2729
28- // @ts -ignore
30+ /** @param { string } value */
2931 function addColorScheme ( value ) {
3032 const className = '<%= options.classPrefix %>' + value + '<%= options.classSuffix %>'
3133 const dataValue = '<%= options.dataValue %>'
3941 }
4042 }
4143
42- // @ts -ignore
44+ /** @param { string } value */
4345 function removeColorScheme ( value ) {
4446 const className = '<%= options.classPrefix %>' + value + '<%= options.classSuffix %>'
4547 const dataValue = '<%= options.dataValue %>'
5355 }
5456 }
5557
56- // @ts -ignore
58+ /** @param { string } suffix */
5759 function prefersColorScheme ( suffix ) {
5860 return w . matchMedia ( '(prefers-color-scheme' + suffix + ')' )
5961 }
6062
6163 function getColorScheme ( ) {
62- // @ts -ignore
63- if ( w . matchMedia && prefersColorScheme ( '' ) . media !== 'not all' ) {
64+ if (
65+ // @ts -expect-error TS assumes matchMedia is always defined
66+ w . matchMedia
67+ && prefersColorScheme ( '' ) . media !== 'not all' ) {
6468 for ( const colorScheme of knownColorSchemes ) {
6569 if ( prefersColorScheme ( ':' + colorScheme ) . matches ) {
6670 return colorScheme
Original file line number Diff line number Diff line change 1- script . ts
1+ script . js
You can’t perform that action at this time.
0 commit comments