Skip to content

Commit

Permalink
Merge pull request #120 from elycruz/dev
Browse files Browse the repository at this point in the history
issue-#119 - Updated 'SassOptions' type to use the 'sass' package's one.
  • Loading branch information
elycruz authored Oct 7, 2023
2 parents c1632a6 + ca4e47b commit b7ff343
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-sass",
"version": "1.12.20",
"version": "1.12.21",
"description": "Rollup Sass files.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export = function plugin(options = {} as RollupPluginSassOptions): RollupPlugin
include = defaultIncludes,
exclude = defaultExcludes,
runtime: sassRuntime,
options: incomingSassOptions = {}
options: incomingSassOptions = {} as SassOptions
} = pluginOptions,

filter = createFilter(include || '', exclude || ''),
Expand Down
35 changes: 14 additions & 21 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {types} from 'sass';
import {LegacyOptions, types} from 'sass';

export interface IdAndContentObject {
id?: string,
Expand Down Expand Up @@ -58,37 +58,30 @@ export type SassImporterResult = { file: string } | { contents: string } | Error
export type SassDoneFn<T extends SassImporterResult = SassImporterResult> =
(result: T) => void | T;

/**
* @deprecated - Use types directly from `sass` package instead.
*/
export type SassImporter<T extends SassImporterResult = SassImporterResult> =
(url: string, prev: string, done: SassDoneFn<T>) => void | T;

/**
* @deprecated - Use types directly from `sass` package instead.
*/
export interface SassFunctionsObject {
[index: string]: types.Color | types.Number | types.String | types.List | types.Map | types.Null;
}

/**
* All option types taken from https://github.com/sass/node-sass#options -
* **Note:** As noted by dart-sass project "When installed via npm, Dart Sass supports a JavaScript API that's fully
* compatible with Node Sass (with a few exceptions listed below) ...". See the (dart) sass npm page for more:
* **Note 1:** As noted by dart-sass project "When installed via npm, Dart Sass supports a JavaScript API that's fully compatible with Node Sass (with a few exceptions listed below) ...". See the (dart) sass npm page for more:
* https://www.npmjs.com/package/sass
*
* **Note 2:** Our plugin only uses the "legacy" (async) API (internally) so `SassOptions` type below, for now,
* is the legacy type.
*
* @todo Update this if/when we update to the new sass API.
*/
export interface SassOptions {
data?: string,
file?: string,
functions?: SassFunctionsObject,
importer?: SassImporter | SassImporter[],
includePaths?: string[],
indentType?: 'space' | 'tab',
indentWidth?: number,
indentedSyntax?: boolean,
linefeed?: string,
omitSourceMapUrl?: boolean,
outFile?: string,
outputStyle?: 'compressed' | 'expanded',
sourceMapContents?: boolean,
sourceMapEmbed?: boolean,
sourceMapRoot?: string,
sourceMap?: boolean | string | undefined
}
export type SassOptions = LegacyOptions<'async'>;

/**
* Rollup's `AssetInfo` bundle type.
Expand Down

0 comments on commit b7ff343

Please sign in to comment.