Skip to content

Commit

Permalink
add build config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvester Aswin Stanley committed Jan 6, 2021
1 parent 2663855 commit a6ca6f7
Show file tree
Hide file tree
Showing 44 changed files with 120 additions and 112 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ module.exports = {
es6: true,
node: true,
},
overrides: [
{
files: ["./example/**/*.js"],
rules: {
// Allow require statement for all JS files
"@typescript-eslint/no-var-requires": "off",
},
},
],
};
51 changes: 25 additions & 26 deletions example/example.config.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
const path = require("path");
const {
plugins: { docs, json },
util: { defineClass },
modules: { font, colors, border, boxShadow }
} = require("../src/index");
modules: { font, colors, border, boxShadow },
} = require("../dist/index");

const breakPoints = {
ns: "screen and (min-width: 48rem)",
m: "screen and (min-width: 48rem) and (max-width: 80rem)",
l: "screen and (min-width: 80rem)"
l: "screen and (min-width: 80rem)",
};

const plugins = [
json({
output: path.join(__dirname, "/dist/example.json")
output: path.join(__dirname, "/dist/example.json"),
}),
docs({
output: path.join(__dirname, "/dist/docs.html"),
openFile: true
})
openFile: true,
}),
];

const modules = [
boxShadow({
names: {
"bxsh:n": "boxShadowNone",
bxsh: "boxShadow"
bxsh: "boxShadow",
},
boxShadowValues: {
xs: "0 0 0 1px rgba(0, 0, 0, 0.05)",
inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"
inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)",
},
whitelist: ["bxsh:n", "bxsh"]
whitelist: ["bxsh:n", "bxsh"],
}),
border({
names: {
"bd:w": "borderWidth",
"bd:s": "borderStyle",
"bd:n": "borderNone"
"bd:n": "borderNone",
},
whitelist: ["bd:w", "bd:s", "bd:n"],
borderStyleValues: ["solid", "dotted"],
borderWidthValues: ["1px", "2px"],
pseudoClasses: { "bd:n": [":hover"] },
isResponsive: true,
responsiveWhiteList: ["bd:n"]
responsiveWhiteList: ["bd:n"],
}),
font({
names: { fz: "f" },
Expand All @@ -59,9 +58,9 @@ const modules = [
"1.625rem",
"1.75rem",
"1.875rem",
"2rem"
"2rem",
],
isResponsive: true
isResponsive: true,
}),
colors({
nestedRules: {
Expand All @@ -70,16 +69,16 @@ const modules = [
isResponsive: true,
colorValues: {
black: "#ffffff",
white: "#1a1a1a"
}
white: "#1a1a1a",
},
},
"@media foo": {
whitelist: ["c"],
colorValues: {
black: "#ffffff",
white: "#1a1a1a"
}
}
white: "#1a1a1a",
},
},
},
whitelist: ["c", "bgc", "bdc"],
pseudoClasses: { c: [":hover"], bgc: [":hover", ":active"] },
Expand All @@ -92,32 +91,32 @@ const modules = [
grey3: "#dddddd",
red: "#ce3535",
green: "#0f7e4a",
blue: "#0062b4"
blue: "#0062b4",
},
backgroundColorValues: {
white: "#f3f3f3",
pink: "#fde5e5",
green: "#e0f3ea",
yellow: "#fffdc0"
yellow: "#fffdc0",
},
borderColorValues: {
orange: "#ff6900",
black: "#1a1a1a",
white: "#ffffff",
grey: "#a5a5a5",
green: "#0f7e4a",
red: "#ce3535"
}
})
red: "#ce3535",
},
}),
];

module.exports = {
forceInsert: true,
config: {
breakPoints,
breakPointSeparator: "_",
pseudoClassesSeparator: "_"
pseudoClassesSeparator: "_",
},
modules,
plugins
plugins,
};
4 changes: 2 additions & 2 deletions example/module.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
"1.625rem",
"1.75rem",
"1.875rem",
"2rem"
"2rem",
],
isResponsive: true
isResponsive: true,
};
8 changes: 4 additions & 4 deletions example/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const _ = require("lodash");
const utility = require("../src/index");
const utility = require("../dist/index").default;
const utilityConfig = require("./example.config");

module.exports = {
plugins: [
utility(
Object.assign({}, utilityConfig, {
forceInsert: _.includes(process.argv, "forceInsert")
forceInsert: _.includes(process.argv, "forceInsert"),
})
)
]
),
],
};
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chalk from "chalk";
import path from "path";
import fs from "fs";
import { promises as fsAsync } from "fs";
import { builder } from "../";
import builder from "./";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require("../package.json");
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import deepmerge from "deepmerge";
import computeStyles from "./util/computeStyles";

const AT_RULE_NAME = "utility";
const DEFAULT_CONFIG_PATH = "./utility.config.default.ts";
const DEFAULT_CONFIG_PATH = "./utility.config.default";

const builder = postcss.plugin("utility", (config) => (styles) => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down Expand Up @@ -102,7 +102,7 @@ const builder = postcss.plugin("utility", (config) => (styles) => {
});
});

export { builder };
export default builder;

export * as plugins from "./plugins";
export * as modules from "./modules";
Expand Down
4 changes: 2 additions & 2 deletions src/modules/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const meta: Meta = {
module: "animation",
};

const module: AnimationModuleType = (config) => (globalConfig) => {
const cssModule: AnimationModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -34,4 +34,4 @@ const module: AnimationModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/background-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const meta: Meta = {
module: "background-image",
};

const module: BackgroundImageModuleType = (config) => (globalConfig) => {
const cssModule: BackgroundImageModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -144,4 +144,4 @@ const module: BackgroundImageModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/border.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const meta: Meta = {
module: "border",
};

const module: BorderModuleType = (config) => (globalConfig) => {
const cssModule: BorderModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -197,4 +197,4 @@ const module: BorderModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/box-shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const meta: Meta = {
module: "box-shadow",
};

const module: BoxShadowModuleType = (config) => (globalConfig) => {
const cssModule: BoxShadowModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -41,4 +41,4 @@ const module: BoxShadowModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/box-sizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const meta: Meta = {
module: "box-sizing",
};

const module: BoxSizingModuleType = (config) => (globalConfig) => {
const cssModule: BoxSizingModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -35,4 +35,4 @@ const module: BoxSizingModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const meta: Meta = {
module: "clear",
};

const module: ClearModuleType = (config) => (globalConfig) => {
const cssModule: ClearModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -39,4 +39,4 @@ const module: ClearModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const meta: Meta = {
module: "colors",
};

const module: ColorsModuleType = (config) => (globalConfig) => {
const cssModule: ColorsModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -72,4 +72,4 @@ const module: ColorsModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const meta: Meta = {
module: "cursor",
};

const module: CursorModuleType = (config) => (globalConfig) => {
const cssModule: CursorModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -47,4 +47,4 @@ const module: CursorModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const meta: Meta = {
module: "display",
};

const module: DisplayModuleType = (config) => (globalConfig) => {
const cssModule: DisplayModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -93,4 +93,4 @@ const module: DisplayModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/flexbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const meta: Meta = {
module: "flexbox",
};

const module: FlexBoxModuleType = (config) => (globalConfig) => {
const cssModule: FlexBoxModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -149,4 +149,4 @@ const module: FlexBoxModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const meta: Meta = {
module: "float",
};

const module: FloatModuleType = (config) => (globalConfig) => {
const cssModule: FloatModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -37,4 +37,4 @@ const module: FloatModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const meta: Meta = {
module: "font",
};

const module: FontModuleType = (config) => (globalConfig) => {
const cssModule: FontModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -145,4 +145,4 @@ const module: FontModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
4 changes: 2 additions & 2 deletions src/modules/height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const meta: Meta = {
module: "height",
};

const module: HeightModuleType = (config) => (globalConfig) => {
const cssModule: HeightModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
Expand All @@ -44,4 +44,4 @@ const module: HeightModuleType = (config) => (globalConfig) => {
});
};

export default module;
export default cssModule;
Loading

0 comments on commit a6ca6f7

Please sign in to comment.