@muonic/muon 0.0.2-beta.4 → 0.0.2-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.6](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.5...v0.0.2-beta.6) (2023-03-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * postcss extend ([7608e26](https://github.com/centrica-engineering/muon/commit/7608e26e1f1876abacbca562fb6724bebc0cbf50))
11
+
12
+ ### [0.0.2-beta.5](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.4...v0.0.2-beta.5) (2023-02-27)
13
+
14
+
15
+ ### Features
16
+
17
+ * global styles ([6705c22](https://github.com/centrica-engineering/muon/commit/6705c224f7664e1ab6ad9d7261921474de1bf0fc))
18
+
5
19
  ### [0.0.2-beta.4](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.3...v0.0.2-beta.4) (2023-02-23)
6
20
 
7
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.4",
3
+ "version": "0.0.2-beta.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,6 +42,7 @@
42
42
  "path-is-inside": "1.0.2",
43
43
  "postcss": "8.4.14",
44
44
  "postcss-clean": "1.2.2",
45
+ "postcss-extend-rule": "^4.0.0",
45
46
  "postcss-import": "14.1.0",
46
47
  "postcss-preset-env": "7.7.2",
47
48
  "postcss-simple-vars": "6.0.3",
@@ -3,9 +3,11 @@ import stylesPlugin from 'rollup-plugin-styles';
3
3
  import replacePlugin from '@rollup/plugin-replace';
4
4
  import aliasPlugin from '@rollup/plugin-alias';
5
5
  import autoprefixer from 'autoprefixer';
6
+ import postcss from 'postcss';
6
7
  import postcssPreset from 'postcss-preset-env';
7
8
  import postcssImport from 'postcss-import';
8
9
  import postcssVariables from 'postcss-simple-vars';
10
+ import postcssExtendRule from 'postcss-extend-rule';
9
11
  import litcssPlugin from 'rollup-plugin-lit-css';
10
12
  import { cleanup, getConfig, getDestination, createTokens, sourceFilesAnalyzer, getAliasPaths } from './utils/index.mjs';
11
13
 
@@ -18,19 +20,6 @@ const __dirname = path.dirname(__filename);
18
20
 
19
21
  const config = getConfig();
20
22
 
21
- const muonPlugin = () => {
22
- return {
23
- name: 'muon',
24
- async buildStart() {
25
- const destination = getDestination();
26
- cleanup(destination, true).then(async () => {
27
- const cejson = await sourceFilesAnalyzer();
28
- fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
29
- });
30
- }
31
- };
32
- };
33
-
34
23
  const tokenPath = path.join(__dirname, '..', 'build', 'tokens', 'es6', 'muon-tokens.mjs');
35
24
  let designTokens = {};
36
25
 
@@ -44,17 +33,6 @@ const buildTokensPlugin = () => {
44
33
  };
45
34
  };
46
35
 
47
- const styles = fromRollup(stylesPlugin);
48
- const replace = fromRollup(replacePlugin);
49
- const litcss = fromRollup(litcssPlugin);
50
- const alias = fromRollup(aliasPlugin);
51
- const muon = fromRollup(muonPlugin);
52
- const buildTokens = fromRollup(buildTokensPlugin);
53
-
54
- const aliasConfig = {
55
- entries: getAliasPaths('regex')
56
- };
57
-
58
36
  const postcssPlugins = [
59
37
  postcssVariables({
60
38
  variables() {
@@ -71,18 +49,72 @@ const postcssPlugins = [
71
49
  'logical-properties-and-values': false /* allowing start end values */
72
50
  }
73
51
  }),
52
+ postcssExtendRule(),
74
53
  autoprefixer({ grid: true })
75
54
  ];
76
55
 
77
- // @TODO: bring back when global css is used
78
- // const createGlobalCSS = async (destination) => {
79
- // const globalCSSUrl = path.join(__filename, '..', '..', '..', 'css', 'global.css');
80
- // const globalCSSDest = path.join(destination, 'muon.min.css');
81
- // const globalCSS = fs.readFileSync(globalCSSUrl);
82
- // const processedCSS = await postcss(postcssPlugins).process(globalCSS, { from: globalCSSUrl, to: globalCSSDest });
56
+ const createGlobalCSS = async () => {
57
+ const globalCSSUrl = path.join(process.cwd(), 'css', 'global.css');
58
+
59
+ if (fs.existsSync(globalCSSUrl)) {
60
+ const globalCSS = fs.readFileSync(globalCSSUrl);
61
+ const processedCSS = await postcss(postcssPlugins).process(globalCSS, { from: globalCSSUrl });
62
+ return processedCSS.css;
63
+ }
64
+
65
+ return undefined;
66
+ };
83
67
 
84
- // fs.writeFileSync(globalCSSDest, processedCSS.css, 'utf8');
85
- // };
68
+ const muonPlugin = () => {
69
+ return {
70
+ name: 'muon',
71
+ async buildStart() {
72
+ const destination = getDestination();
73
+ cleanup(destination, true).then(async () => {
74
+ const cejson = await sourceFilesAnalyzer();
75
+ fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
76
+ });
77
+ },
78
+ async transform(code, id) {
79
+ if (id.includes(path.join('muon', 'index.js'))) {
80
+ const globalCSS = await createGlobalCSS();
81
+
82
+ if (!globalCSS) {
83
+ return null;
84
+ }
85
+
86
+ if (!code?.includes('globalCSS')) {
87
+ return {
88
+ code: `
89
+ const globalCSS = document.createElement('style');
90
+ globalCSS.innerHTML = \`${globalCSS}\`;
91
+ document.head.appendChild(globalCSS);
92
+ ${code}
93
+ `,
94
+ map: null
95
+ };
96
+ } else {
97
+ return {
98
+ code
99
+ };
100
+ }
101
+ }
102
+
103
+ return null;
104
+ }
105
+ };
106
+ };
107
+
108
+ const styles = fromRollup(stylesPlugin);
109
+ const replace = fromRollup(replacePlugin);
110
+ const litcss = fromRollup(litcssPlugin);
111
+ const alias = fromRollup(aliasPlugin);
112
+ const muon = fromRollup(muonPlugin);
113
+ const buildTokens = fromRollup(buildTokensPlugin);
114
+
115
+ const aliasConfig = {
116
+ entries: getAliasPaths('regex')
117
+ };
86
118
 
87
119
  const styleConfig = {
88
120
  mode: 'emit',
@@ -9,6 +9,9 @@ export default {
9
9
  nodeResolve: true,
10
10
  mimeTypes: {
11
11
  '**/*.json': 'js',
12
+ '**/css/*.css': 'text/css',
13
+ '**/dist/*.css': 'text/css',
14
+ 'muon.min.css': 'text/css',
12
15
  '**/*.css': 'js'
13
16
  },
14
17
  plugins: [