Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Config changes / umd
Browse files Browse the repository at this point in the history
  • Loading branch information
nsaunders committed May 5, 2020
1 parent 9858ebd commit 32ef7d8
Show file tree
Hide file tree
Showing 10 changed files with 6,834 additions and 1,979 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@babel/env",
{
"useBuiltIns": "usage",
"corejs": 3,
},
]
]
}
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
last 2 versions, not dead
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports = {
extends: "@hacss",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.eslintcache
dist
10 changes: 0 additions & 10 deletions index.js

This file was deleted.

8,697 changes: 6,755 additions & 1,942 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "Create simple shorthand properties that expand one declaration into multiple.",
"main": "index.js",
"scripts": {
"test": "mocha test"
"prepublishOnly": "webpack",
"pretest": "webpack",
"test": "node test"
},
"repository": {
"type": "git",
Expand All @@ -28,20 +30,23 @@
},
"homepage": "https://hacss.io/",
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@hacss/compose-plugins": "^1.0.1",
"@hacss/eslint-config": "^1.0.0",
"@hacss/plugin-copy": "^1.1.0",
"@hacss/plugin-delete": "^1.1.0",
"@hacss/prettier-config": "^1.0.0",
"chai": "^4.2.0",
"babel-loader": "^8.1.0",
"core-js-pure": "^3.6.5",
"eslint": "^6.8.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.2",
"mocha": "^7.1.2",
"prettier": "^2.0.5"
},
"dependencies": {
"@hacss/compose-plugins": "^1.0.1",
"@hacss/plugin-copy": "^1.0.0",
"@hacss/plugin-delete": "^1.0.0"
"prettier": "^2.0.5",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"dependencies": {},
"prettier": "@hacss/prettier-config",
"husky": {
"hooks": {
Expand All @@ -54,5 +59,8 @@
"eslint --cache --fix",
"npm test"
]
},
"peerDependencies": {
"@hacss/core": "^1.0.0"
}
}
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import compose from "@hacss/compose-plugins";
import copy from "@hacss/plugin-copy/src/index.js";
import del from "@hacss/plugin-delete/src/index.js";

export default spec => compose(del(Object.keys(spec)), copy(spec));
35 changes: 17 additions & 18 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
const { expect } = require("chai");
const expandPlugin = require("../index.js");
const assert = require("assert");
const expandPlugin = require("../dist/hacss-plugin-expand.umd.js");

describe("expand plugin", () => {
const spec = {
"margin-x": ["margin-left", "margin-right"],
};
const spec = {
"margin-x": ["margin-left", "margin-right"],
};

const [ expand, properties ] = expandPlugin(spec);
const test = (actual, expected) => {
console.log(`${JSON.stringify(actual)} === ${JSON.stringify(expected)}`);
assert.deepEqual(actual, expected);
};

it("should expand specified properties", () => {
expect(expand({ "margin-x": "20px", "padding-top": "40px" }))
.to.deep.equal({
"margin-left": "20px",
"margin-right": "20px",
"padding-top": "40px",
});
});
const [expand, properties] = expandPlugin(spec);

it("should add the properties in the spec to the list of recognized properties", () => {
expect(properties).to.deep.equal(Object.keys(spec));
});
test(expand({ "margin-x": "20px", "padding-top": "40px" }), {
"margin-left": "20px",
"margin-right": "20px",
"padding-top": "40px",
});

test(properties, Object.keys(spec));
console.log("All tests passed.");
26 changes: 26 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const path = require("path");

module.exports = [
["hacss-plugin-expand.umd.js", "development"],
["hacss-plugin-expand.umd.min.js", "production"],
].map(([filename, mode]) => ({
entry: "./src/index.js",
output: {
path: path.join(__dirname, "dist"),
filename,
library: ["hacssPlugins", "expand"],
libraryTarget: "umd",
globalObject: "this",
libraryExport: "default",
},
resolve: {
alias: {
"core-js": "core-js-pure",
},
},
module: {
rules: [{ test: /\.js$/, use: "babel-loader" }],
},
mode,
devtool: "source-map",
}));

0 comments on commit 32ef7d8

Please sign in to comment.