@modern-js/plugin-tailwindcss 1.2.0 → 1.2.1
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 +11 -0
- package/package.json +4 -4
- package/src/cli.ts +0 -77
- package/src/index.ts +0 -1
- package/src/tailwind.ts +0 -78
- package/src/types.d.ts +0 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
+
## 1.2.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 83166714: change .npmignore
|
8
|
+
- Updated dependencies [83166714]
|
9
|
+
- Updated dependencies [c3de9882]
|
10
|
+
- Updated dependencies [33ff48af]
|
11
|
+
- @modern-js/core@1.3.2
|
12
|
+
- @modern-js/utils@1.2.2
|
13
|
+
|
3
14
|
## 1.2.0
|
4
15
|
|
5
16
|
### Minor Changes
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.2.
|
14
|
+
"version": "1.2.1",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -33,12 +33,12 @@
|
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
35
|
"@babel/runtime": "^7",
|
36
|
-
"@modern-js/utils": "^1.2.
|
36
|
+
"@modern-js/utils": "^1.2.2",
|
37
37
|
"lodash.clonedeep": "^4.5.0",
|
38
38
|
"lodash.merge": "^4.6.2"
|
39
39
|
},
|
40
40
|
"devDependencies": {
|
41
|
-
"@modern-js/core": "^1.3.
|
41
|
+
"@modern-js/core": "^1.3.2",
|
42
42
|
"@scripts/build": "0.0.0",
|
43
43
|
"@types/jest": "^26",
|
44
44
|
"@types/lodash.clonedeep": "^4.5.6",
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"@scripts/jest-config": "0.0.0"
|
52
52
|
},
|
53
53
|
"peerDependencies": {
|
54
|
-
"@modern-js/core": "^1.3.
|
54
|
+
"@modern-js/core": "^1.3.2",
|
55
55
|
"tailwindcss": "^2.0.4"
|
56
56
|
},
|
57
57
|
"sideEffects": false,
|
package/src/cli.ts
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
import { Import, PLUGIN_SCHEMAS } from '@modern-js/utils';
|
2
|
-
import { getTailwindConfig } from './tailwind';
|
3
|
-
|
4
|
-
const core: typeof import('@modern-js/core') = Import.lazy(
|
5
|
-
'@modern-js/core',
|
6
|
-
require,
|
7
|
-
);
|
8
|
-
|
9
|
-
export default core.createPlugin(
|
10
|
-
() => ({
|
11
|
-
validateSchema() {
|
12
|
-
return PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
|
13
|
-
},
|
14
|
-
config() {
|
15
|
-
return {
|
16
|
-
tools: {
|
17
|
-
// TODO: Add interface about postcss config
|
18
|
-
// TODO: In module project, also is called, but should not be called.
|
19
|
-
postcss: (config: Record<string, any>) => {
|
20
|
-
const modernConfig = core.useResolvedConfigContext();
|
21
|
-
const tailwindConfig = getTailwindConfig(modernConfig, {
|
22
|
-
pureConfig: {
|
23
|
-
content: [
|
24
|
-
'./config/html/**/*.html',
|
25
|
-
'./config/html/**/*.ejs',
|
26
|
-
'./config/html/**/*.hbs',
|
27
|
-
'./src/**/*.js',
|
28
|
-
'./src/**/*.jsx',
|
29
|
-
'./src/**/*.ts',
|
30
|
-
'./src/**/*.tsx',
|
31
|
-
// about storybook
|
32
|
-
'./storybook/**/*',
|
33
|
-
'./styles/**/*.less',
|
34
|
-
'./styles/**/*.css',
|
35
|
-
'./styles/**/*.sass',
|
36
|
-
'./styles/**/*.scss',
|
37
|
-
],
|
38
|
-
},
|
39
|
-
});
|
40
|
-
if (Array.isArray(config.postcssOptions.plugins)) {
|
41
|
-
config.postcssOptions.plugins.push(
|
42
|
-
require('tailwindcss')(tailwindConfig),
|
43
|
-
);
|
44
|
-
} else {
|
45
|
-
config.postcssOptions.plugins = [
|
46
|
-
require('tailwindcss')(tailwindConfig),
|
47
|
-
];
|
48
|
-
}
|
49
|
-
},
|
50
|
-
},
|
51
|
-
};
|
52
|
-
},
|
53
|
-
moduleTailwindConfig() {
|
54
|
-
const modernConfig = core.useResolvedConfigContext();
|
55
|
-
const tailwindConfig = getTailwindConfig(modernConfig, {
|
56
|
-
pureConfig: {
|
57
|
-
content: [
|
58
|
-
'./src/**/*.js',
|
59
|
-
'./src/**/*.jsx',
|
60
|
-
'./src/**/*.ts',
|
61
|
-
'./src/**/*.tsx',
|
62
|
-
'./src/**/*.less',
|
63
|
-
'./src/**/*.css',
|
64
|
-
'./src/**/*.sass',
|
65
|
-
'./src/**/*.scss',
|
66
|
-
'./styles/**/*.less',
|
67
|
-
'./styles/**/*.css',
|
68
|
-
'./styles/**/*.sass',
|
69
|
-
'./styles/**/*.scss',
|
70
|
-
],
|
71
|
-
},
|
72
|
-
});
|
73
|
-
return require('tailwindcss')(tailwindConfig);
|
74
|
-
},
|
75
|
-
}),
|
76
|
-
{ name: '@modern-js/plugin-tailwindcss' },
|
77
|
-
) as any;
|
package/src/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from './cli';
|
package/src/tailwind.ts
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
2
|
-
import { Import, applyOptionsChain, logger } from '@modern-js/utils';
|
3
|
-
|
4
|
-
const cloneDeep: typeof import('lodash.clonedeep') = Import.lazy(
|
5
|
-
'lodash.clonedeep',
|
6
|
-
require,
|
7
|
-
);
|
8
|
-
const merge: typeof import('lodash.merge') = Import.lazy(
|
9
|
-
'lodash.merge',
|
10
|
-
require,
|
11
|
-
);
|
12
|
-
|
13
|
-
const checkIfExistNotAllowKeys = (
|
14
|
-
tailwindConfig: Record<string, any>,
|
15
|
-
): [boolean, string] => {
|
16
|
-
const notAllowExistKeys = ['theme'];
|
17
|
-
let notAllowKey = '';
|
18
|
-
|
19
|
-
const ret = Object.keys(tailwindConfig).some(
|
20
|
-
key => notAllowExistKeys.includes(key) && (notAllowKey = key),
|
21
|
-
);
|
22
|
-
|
23
|
-
return [ret, notAllowKey];
|
24
|
-
};
|
25
|
-
|
26
|
-
const getPureDesignSystemConfig = (
|
27
|
-
designSystemConfig: Record<string, any> & {
|
28
|
-
supportSytledComponents: boolean;
|
29
|
-
},
|
30
|
-
) => {
|
31
|
-
const pureDesignSystemConfig = cloneDeep(designSystemConfig);
|
32
|
-
delete pureDesignSystemConfig.supportStyledComponents;
|
33
|
-
return pureDesignSystemConfig;
|
34
|
-
};
|
35
|
-
|
36
|
-
const getTailwindConfig = (
|
37
|
-
config: NormalizedConfig,
|
38
|
-
option: { pureConfig?: Record<string, any> } = {},
|
39
|
-
) => {
|
40
|
-
const purgeConfig = merge(
|
41
|
-
{
|
42
|
-
// TODO: how the operating environment is determined
|
43
|
-
enabled: process.env.NODE_ENV === 'production',
|
44
|
-
// TODO: Remove or not
|
45
|
-
layers: ['utilities'],
|
46
|
-
content: [],
|
47
|
-
},
|
48
|
-
option.pureConfig || {},
|
49
|
-
);
|
50
|
-
const defaultTailwindConfig = {
|
51
|
-
purge: purgeConfig,
|
52
|
-
};
|
53
|
-
const tailwindConfig = applyOptionsChain(
|
54
|
-
defaultTailwindConfig,
|
55
|
-
(config.tools as any).tailwindcss || {},
|
56
|
-
);
|
57
|
-
|
58
|
-
const designSystem = getPureDesignSystemConfig(
|
59
|
-
(config.source as any).designSystem || {},
|
60
|
-
);
|
61
|
-
|
62
|
-
const [exist, key] = checkIfExistNotAllowKeys(tailwindConfig);
|
63
|
-
|
64
|
-
if (exist) {
|
65
|
-
logger.error(
|
66
|
-
`should not exist '${key}' on tools.tailwindcss, please remove it`,
|
67
|
-
);
|
68
|
-
// eslint-disable-next-line no-process-exit
|
69
|
-
process.exit(0);
|
70
|
-
}
|
71
|
-
|
72
|
-
// Because there is no default theme configuration
|
73
|
-
tailwindConfig.theme = designSystem || {};
|
74
|
-
|
75
|
-
return tailwindConfig;
|
76
|
-
};
|
77
|
-
|
78
|
-
export { getTailwindConfig };
|
package/src/types.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import '@modern-js/core';
|
2
|
-
|
3
|
-
declare module '@modern-js/core' {
|
4
|
-
interface ToolsConfig {
|
5
|
-
tailwind?:
|
6
|
-
| Record<string, any>
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
8
|
-
| ((options: Record<string, any>) => Record<string, any> | void);
|
9
|
-
}
|
10
|
-
}
|