Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing sourceMap options to PostCSS #147

Merged
merged 7 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deps/postcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as postcss } from "https://deno.land/x/postcss@8.3.11/mod.js";
export { default as postcssImport } from "https://deno.land/x/postcss_import@0.1.4/mod.js";
export { default as postcssNesting } from "https://cdn.jsdelivr.net/gh/csstools/postcss-nesting@9.0.0/mod.js";
export { default as autoprefixer } from "https://deno.land/x/postcss_autoprefixer@0.1.1/mod.js";
export type { SourceMapOptions } from "https://deno.land/x/postcss@8.3.11/lib/postcss.d.ts";
5 changes: 3 additions & 2 deletions plugins/postcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
postcss,
postcssImport,
postcssNesting,
SourceMapOptions,
} from "../deps/postcss.ts";
import { merge } from "../core/utils.ts";
import { Helper, Page, Site } from "../core.ts";
Expand All @@ -13,7 +14,7 @@ export interface Options {
extensions: string[];

/** Set `true` to generate source map files */
sourceMap: boolean;
sourceMap: boolean | SourceMapOptions;

/** Custom includes path for `postcss-import` */
includes: string | string[] | false;
Expand Down Expand Up @@ -69,7 +70,7 @@ export default function (userOptions?: Partial<Options>) {
async function postCss(file: Page) {
const from = site.src(file.src.path + file.src.ext);
const to = site.dest(file.dest.path + file.dest.ext);
const map = options.sourceMap ? { inline: false } : undefined;
const map = options.sourceMap;

// Process the code with PostCSS
const result = await runner.process(file.content!, { from, to, map });
Expand Down