@muonic/muon 0.0.2-experimental-166-296abd5.0 → 0.0.2-experimental-169-a1cb639.0
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 +7 -0
- package/package.json +1 -1
- package/scripts/rollup-plugins.mjs +62 -32
- package/storybook/server.config.mjs +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.5](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.4...v0.0.2-beta.5) (2023-02-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* global styles ([6705c22](https://github.com/centrica-engineering/muon/commit/6705c224f7664e1ab6ad9d7261921474de1bf0fc))
|
|
11
|
+
|
|
5
12
|
### [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
13
|
|
|
7
14
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ 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';
|
|
@@ -18,19 +19,6 @@ const __dirname = path.dirname(__filename);
|
|
|
18
19
|
|
|
19
20
|
const config = getConfig();
|
|
20
21
|
|
|
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
22
|
const tokenPath = path.join(__dirname, '..', 'build', 'tokens', 'es6', 'muon-tokens.mjs');
|
|
35
23
|
let designTokens = {};
|
|
36
24
|
|
|
@@ -44,17 +32,6 @@ const buildTokensPlugin = () => {
|
|
|
44
32
|
};
|
|
45
33
|
};
|
|
46
34
|
|
|
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
35
|
const postcssPlugins = [
|
|
59
36
|
postcssVariables({
|
|
60
37
|
variables() {
|
|
@@ -74,15 +51,68 @@ const postcssPlugins = [
|
|
|
74
51
|
autoprefixer({ grid: true })
|
|
75
52
|
];
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
const createGlobalCSS = async () => {
|
|
55
|
+
const globalCSSUrl = path.join(process.cwd(), 'css', 'global.css');
|
|
56
|
+
|
|
57
|
+
if (fs.existsSync(globalCSSUrl)) {
|
|
58
|
+
const globalCSS = fs.readFileSync(globalCSSUrl);
|
|
59
|
+
const processedCSS = await postcss(postcssPlugins).process(globalCSS, { from: globalCSSUrl });
|
|
60
|
+
return processedCSS.css;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
83
65
|
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
const muonPlugin = () => {
|
|
67
|
+
return {
|
|
68
|
+
name: 'muon',
|
|
69
|
+
async buildStart() {
|
|
70
|
+
const destination = getDestination();
|
|
71
|
+
cleanup(destination, true).then(async () => {
|
|
72
|
+
const cejson = await sourceFilesAnalyzer();
|
|
73
|
+
fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
async transform(code, id) {
|
|
77
|
+
if (id.includes(path.join('muon', 'index.js'))) {
|
|
78
|
+
const globalCSS = await createGlobalCSS();
|
|
79
|
+
|
|
80
|
+
if (!globalCSS) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!code?.includes('globalCSS')) {
|
|
85
|
+
return {
|
|
86
|
+
code: `
|
|
87
|
+
const globalCSS = document.createElement('style');
|
|
88
|
+
globalCSS.innerHTML = \`${globalCSS}\`;
|
|
89
|
+
document.head.appendChild(globalCSS);
|
|
90
|
+
${code}
|
|
91
|
+
`,
|
|
92
|
+
map: null
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
return {
|
|
96
|
+
code
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const styles = fromRollup(stylesPlugin);
|
|
107
|
+
const replace = fromRollup(replacePlugin);
|
|
108
|
+
const litcss = fromRollup(litcssPlugin);
|
|
109
|
+
const alias = fromRollup(aliasPlugin);
|
|
110
|
+
const muon = fromRollup(muonPlugin);
|
|
111
|
+
const buildTokens = fromRollup(buildTokensPlugin);
|
|
112
|
+
|
|
113
|
+
const aliasConfig = {
|
|
114
|
+
entries: getAliasPaths('regex')
|
|
115
|
+
};
|
|
86
116
|
|
|
87
117
|
const styleConfig = {
|
|
88
118
|
mode: 'emit',
|