@modern-js/plugin-tailwindcss 1.1.3-rc.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 +36 -10
- package/dist/js/node/cli.js +1 -1
- package/dist/js/node/index.js +15 -0
- package/dist/types/index.d.ts +1 -0
- package/jest.config.js +8 -0
- package/package.json +19 -9
- package/tests/index.test.ts +7 -0
- package/tsconfig.json +1 -3
- package/src/cli.ts +0 -73
- package/src/tailwind.ts +0 -78
- package/src/types.d.ts +0 -10
package/CHANGELOG.md
CHANGED
@@ -1,18 +1,44 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
-
## 1.1
|
3
|
+
## 1.2.1
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
8
|
-
- Updated dependencies [
|
9
|
-
- Updated dependencies [
|
10
|
-
- Updated dependencies [
|
11
|
-
-
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
|
14
|
+
## 1.2.0
|
15
|
+
|
16
|
+
### Minor Changes
|
17
|
+
|
18
|
+
- cfe11628: Make Modern.js self bootstraping
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- Updated dependencies [2da09c69]
|
23
|
+
- Updated dependencies [fc71e36f]
|
24
|
+
- Updated dependencies [c3d46ee4]
|
25
|
+
- Updated dependencies [cfe11628]
|
26
|
+
- @modern-js/utils@1.2.0
|
27
|
+
- @modern-js/core@1.3.0
|
28
|
+
|
29
|
+
## 1.1.3
|
30
|
+
|
31
|
+
### Patch Changes
|
32
|
+
|
33
|
+
- ca7dcb32: fix ignore style files in src dir
|
34
|
+
- Updated dependencies [90eeb72c]
|
35
|
+
- Updated dependencies [e04914ce]
|
36
|
+
- Updated dependencies [5a4c557e]
|
37
|
+
- Updated dependencies [e04914ce]
|
38
|
+
- Updated dependencies [ca7dcb32]
|
39
|
+
- Updated dependencies [ecb344dc]
|
40
|
+
- @modern-js/core@1.2.0
|
41
|
+
- @modern-js/utils@1.1.5
|
16
42
|
|
17
43
|
## 1.1.2
|
18
44
|
|
package/dist/js/node/cli.js
CHANGED
@@ -44,7 +44,7 @@ var _default = core.createPlugin(() => ({
|
|
44
44
|
const modernConfig = core.useResolvedConfigContext();
|
45
45
|
const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
|
46
46
|
pureConfig: {
|
47
|
-
content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
47
|
+
content: ['./src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', './src/**/*.less', './src/**/*.css', './src/**/*.sass', './src/**/*.scss', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
48
48
|
}
|
49
49
|
});
|
50
50
|
return require('tailwindcss')(tailwindConfig);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "default", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _cli.default;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _cli = _interopRequireDefault(require("./cli"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './cli';
|
package/jest.config.js
ADDED
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.1
|
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",
|
@@ -20,33 +20,38 @@
|
|
20
20
|
"exports": {
|
21
21
|
".": {
|
22
22
|
"node": {
|
23
|
+
"jsnext:source": "./src/index.ts",
|
23
24
|
"import": "./dist/js/modern/index.js",
|
24
25
|
"require": "./dist/js/node/index.js"
|
25
26
|
},
|
26
27
|
"default": "./dist/js/treeshaking/index.js"
|
27
28
|
},
|
28
|
-
"./cli":
|
29
|
+
"./cli": {
|
30
|
+
"jsnext:source": "./src/cli.ts",
|
31
|
+
"default": "./dist/js/node/cli.js"
|
32
|
+
}
|
29
33
|
},
|
30
34
|
"dependencies": {
|
31
35
|
"@babel/runtime": "^7",
|
32
|
-
"@modern-js/utils": "^1.
|
36
|
+
"@modern-js/utils": "^1.2.2",
|
33
37
|
"lodash.clonedeep": "^4.5.0",
|
34
38
|
"lodash.merge": "^4.6.2"
|
35
39
|
},
|
36
40
|
"devDependencies": {
|
37
|
-
"@modern-js/core": "^1.
|
38
|
-
"@
|
39
|
-
"@modern-js/plugin-testing": "^1.1.1",
|
41
|
+
"@modern-js/core": "^1.3.2",
|
42
|
+
"@scripts/build": "0.0.0",
|
40
43
|
"@types/jest": "^26",
|
41
44
|
"@types/lodash.clonedeep": "^4.5.6",
|
42
45
|
"@types/lodash.merge": "^4.6.6",
|
43
46
|
"@types/node": "^14",
|
44
47
|
"@types/tailwindcss": "^2.2.1",
|
45
48
|
"typescript": "^4",
|
46
|
-
"tailwindcss": "^2.0.4"
|
49
|
+
"tailwindcss": "^2.0.4",
|
50
|
+
"jest": "^27",
|
51
|
+
"@scripts/jest-config": "0.0.0"
|
47
52
|
},
|
48
53
|
"peerDependencies": {
|
49
|
-
"@modern-js/core": "^1.
|
54
|
+
"@modern-js/core": "^1.3.2",
|
50
55
|
"tailwindcss": "^2.0.4"
|
51
56
|
},
|
52
57
|
"sideEffects": false,
|
@@ -57,10 +62,15 @@
|
|
57
62
|
}
|
58
63
|
}
|
59
64
|
},
|
65
|
+
"publishConfig": {
|
66
|
+
"registry": "https://registry.npmjs.org/",
|
67
|
+
"access": "public",
|
68
|
+
"types": "./dist/types/index.d.ts"
|
69
|
+
},
|
60
70
|
"scripts": {
|
61
71
|
"new": "modern new",
|
62
72
|
"build": "modern build",
|
63
|
-
"test": "
|
73
|
+
"test": "jest --passWithNoTests"
|
64
74
|
},
|
65
75
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
66
76
|
}
|
package/tsconfig.json
CHANGED
package/src/cli.ts
DELETED
@@ -1,73 +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
|
-
'./styles/**/*.less',
|
63
|
-
'./styles/**/*.css',
|
64
|
-
'./styles/**/*.sass',
|
65
|
-
'./styles/**/*.scss',
|
66
|
-
],
|
67
|
-
},
|
68
|
-
});
|
69
|
-
return require('tailwindcss')(tailwindConfig);
|
70
|
-
},
|
71
|
-
}),
|
72
|
-
{ name: '@modern-js/plugin-tailwindcss' },
|
73
|
-
) as any;
|
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
|
-
}
|