Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 65de5e7

Browse files
committed
Add postCSS config
1 parent cd71c58 commit 65de5e7

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

packages/devtools-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"copy-assets": "node bin/copy-assets",
88
"license-check": "devtools-license-check",
9-
"storybook": "start-storybook -p 9002 -c .storybook -s ./src",
9+
"storybook": "NODE_ENV=storybook start-storybook -p 9002 -c .storybook -s ./src",
1010
"test": "jest"
1111
},
1212
"author": "Jason Laster",

packages/devtools-components/postcss.config.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,36 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
// Dumb export so launchpad does not throw.
6-
module.exports = () => ({});
5+
const mapUrl = require("postcss-url-mapper");
6+
const MC_PATH = "chrome://devtools/skin/images/devtools-components/";
7+
const EXPRESS_PATH = "/devtools-components/images/";
8+
9+
function mapUrlProduction(url, type) {
10+
return url.replace("/images/arrow.svg", MC_PATH + "arrow.svg");
11+
}
12+
13+
function mapUrlDevelopment(url) {
14+
return url.replace("/images/arrow.svg", EXPRESS_PATH + "arrow.svg");
15+
}
16+
17+
module.exports = ({ file, options, env }) => {
18+
// Here we don't want to do anything for storybook since we serve the images thanks
19+
// to the `-s ./src` option in the `storybook` command (see package.json).
20+
if (env === "storybook") {
21+
return {};
22+
}
23+
24+
// This will be used when creating a bundle for mozilla-central (from devtools-reps
25+
// or debugger.html).
26+
if (env === "production") {
27+
return {
28+
plugins: [mapUrl(mapUrlProduction)]
29+
};
30+
}
31+
32+
// This will be used when using this module in launchpad mode. We set a unique path so
33+
// we can serve images from express.
34+
return {
35+
plugins: [mapUrl(mapUrlDevelopment)]
36+
};
37+
};

0 commit comments

Comments
 (0)