Skip to content

Commit

Permalink
chore: add types to rollup configuration
Browse files Browse the repository at this point in the history
Adds a type annotation to the rollup configuration.

Adds missing name to the custom discard CSS plugin.
  • Loading branch information
kleinfreund committed Dec 9, 2021
1 parent ad16fc3 commit 629c953
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion rollup-plugin-discard-css.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/** @typedef {import('rollup').Plugin} RollupPlugin */

/**
* Tiny rollup plugin that discards CSS and ignores everything else.
*
* **Background**:
*
* `vue({ css: false })` wants another plugin to handle bundling the extracted CSS.
* Since I want to bundle an unstyled version of my component, I want to throw that CSS away.
*
* @type {() => RollupPlugin}
*/
export default function discardCss () {
export function discardCss () {
return {
name: 'discard-css',
transform (_code, id) {
return id.endsWith('css') ? { code: '', map: null } : null
},
Expand Down
8 changes: 6 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import postcss from 'rollup-plugin-postcss'
import { terser } from 'rollup-plugin-terser'
import vue from 'rollup-plugin-vue'

import discardCss from './rollup-plugin-discard-css.js'
import { discardCss } from './rollup-plugin-discard-css.js'

/** @typedef {import('rollup').RollupOptions} RollupOptions */

/*
vue options:
Expand Down Expand Up @@ -33,7 +35,7 @@ const unstyledComponentPlugins = [
terser(),
]

export default [
/** @type {RollupOptions[]} */ const options = [
{
input: 'src/index.js',
output: {
Expand Down Expand Up @@ -62,3 +64,5 @@ export default [
plugins: unstyledComponentPlugins,
},
]

export default options

0 comments on commit 629c953

Please sign in to comment.