@modern-js/plugin-tailwindcss 1.2.9 → 1.3.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 +27 -0
- package/dist/js/node/cli.js +111 -36
- package/dist/js/node/utils.js +50 -0
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +32 -8
- package/.eslintrc.js +0 -10
- package/jest.config.js +0 -7
- package/modern.config.js +0 -8
- package/tsconfig.json +0 -11
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# @modern-js/plugin-tailwindcss
|
2
2
|
|
3
|
+
## 1.3.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 8d0eb81f5: support twin.macro
|
8
|
+
|
9
|
+
## 1.2.11
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- a1198d509: feat: bump babel 7.18.0
|
14
|
+
- Updated dependencies [a1198d509]
|
15
|
+
- @modern-js/plugin-design-token@1.0.10
|
16
|
+
|
17
|
+
## 1.2.10
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
|
22
|
+
- Updated dependencies [d32f35134]
|
23
|
+
- Updated dependencies [6ae4a34ae]
|
24
|
+
- Updated dependencies [b80229c79]
|
25
|
+
- Updated dependencies [16ca3151b]
|
26
|
+
- Updated dependencies [948cc4436]
|
27
|
+
- @modern-js/plugin-design-token@1.0.7
|
28
|
+
- @modern-js/utils@1.7.3
|
29
|
+
|
3
30
|
## 1.2.9
|
4
31
|
|
5
32
|
### Patch Changes
|
package/dist/js/node/cli.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default = void 0;
|
6
|
+
exports.getRandomTwConfigFileName = exports.default = void 0;
|
7
7
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
9
9
|
|
@@ -11,52 +11,127 @@ var _cli = _interopRequireDefault(require("@modern-js/plugin-design-token/cli"))
|
|
11
11
|
|
12
12
|
var _tailwind = require("./tailwind");
|
13
13
|
|
14
|
+
var _utils2 = require("./utils");
|
15
|
+
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
17
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
19
|
+
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
21
|
+
|
22
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
23
|
+
|
24
|
+
const supportCssInJsLibrary = 'styled-components';
|
25
|
+
|
26
|
+
const getRandomTwConfigFileName = internalDirectory => {
|
27
|
+
return `${internalDirectory}/tailwind.config.${Date.now()}.${(0, _utils.nanoid)()}.js`;
|
28
|
+
};
|
29
|
+
|
30
|
+
exports.getRandomTwConfigFileName = getRandomTwConfigFileName;
|
31
|
+
|
16
32
|
var _default = () => ({
|
17
33
|
name: '@modern-js/plugin-tailwindcss',
|
18
34
|
// support designSystem.supportStyledComponents
|
19
35
|
usePlugins: [(0, _cli.default)()],
|
20
|
-
setup: api =>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
setup: async api => {
|
37
|
+
const {
|
38
|
+
appDirectory,
|
39
|
+
internalDirectory
|
40
|
+
} = api.useAppContext();
|
41
|
+
let internalTwConfigPath = ''; // When reinstalling dependencies, most of the time the project will be restarted
|
42
|
+
|
43
|
+
const notHaveTwinMacro = await (0, _utils2.checkTwinMacroNotExist)(appDirectory);
|
44
|
+
return {
|
45
|
+
prepare() {
|
46
|
+
if (notHaveTwinMacro) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
|
50
|
+
internalTwConfigPath = getRandomTwConfigFileName(internalDirectory);
|
51
|
+
|
52
|
+
const files = _utils.globby.sync(`${appDirectory}/${_utils.CONFIG_CACHE_DIR}/*.cjs`, {
|
53
|
+
absolute: true
|
54
|
+
});
|
55
|
+
|
56
|
+
if (files.length > 0) {
|
57
|
+
_utils.fs.writeFileSync(internalTwConfigPath, (0, _utils2.template)(files[0]), 'utf-8');
|
58
|
+
}
|
59
|
+
},
|
60
|
+
|
61
|
+
validateSchema() {
|
62
|
+
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-tailwindcss'];
|
63
|
+
},
|
64
|
+
|
65
|
+
config() {
|
66
|
+
return {
|
67
|
+
tools: {
|
68
|
+
// TODO: Add interface about postcss config
|
69
|
+
// TODO: In module project, also is called, but should not be called.
|
70
|
+
postcss: config => {
|
71
|
+
const modernConfig = api.useResolvedConfigContext();
|
72
|
+
const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
|
73
|
+
pureConfig: {
|
74
|
+
content: ['./config/html/**/*.html', './config/html/**/*.ejs', './config/html/**/*.hbs', './src/**/*.js', './src/**/*.jsx', './src/**/*.ts', './src/**/*.tsx', // about storybook
|
75
|
+
'./storybook/**/*', './styles/**/*.less', './styles/**/*.css', './styles/**/*.sass', './styles/**/*.scss']
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
if (Array.isArray(config.postcssOptions.plugins)) {
|
80
|
+
config.postcssOptions.plugins.push(require('tailwindcss')(tailwindConfig));
|
81
|
+
} else {
|
82
|
+
config.postcssOptions.plugins = [require('tailwindcss')(tailwindConfig)];
|
36
83
|
}
|
37
|
-
}
|
84
|
+
},
|
85
|
+
|
86
|
+
babel(config) {
|
87
|
+
var _config$plugins;
|
88
|
+
|
89
|
+
if (notHaveTwinMacro) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
|
93
|
+
const twinConfig = {
|
94
|
+
twin: {
|
95
|
+
preset: supportCssInJsLibrary,
|
96
|
+
config: internalTwConfigPath
|
97
|
+
}
|
98
|
+
};
|
99
|
+
(_config$plugins = config.plugins) === null || _config$plugins === void 0 ? void 0 : _config$plugins.some(plugin => {
|
100
|
+
if (Array.isArray(plugin) && plugin[0]) {
|
101
|
+
const pluginTarget = plugin[0];
|
102
|
+
let pluginOptions = plugin[1];
|
103
|
+
|
104
|
+
if (typeof pluginTarget === 'string' && pluginTarget.includes('compiled/babel-plugin-macros')) {
|
105
|
+
if (pluginOptions) {
|
106
|
+
pluginOptions = _objectSpread(_objectSpread({}, pluginOptions), twinConfig);
|
107
|
+
} else {
|
108
|
+
plugin.push(twinConfig);
|
109
|
+
}
|
38
110
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
111
|
+
return true;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
return false;
|
116
|
+
});
|
43
117
|
}
|
118
|
+
|
44
119
|
}
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
}
|
120
|
+
};
|
121
|
+
},
|
122
|
+
|
123
|
+
moduleTailwindConfig() {
|
124
|
+
const modernConfig = api.useResolvedConfigContext();
|
125
|
+
const tailwindConfig = (0, _tailwind.getTailwindConfig)(modernConfig, {
|
126
|
+
pureConfig: {
|
127
|
+
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']
|
128
|
+
}
|
129
|
+
});
|
130
|
+
return require('tailwindcss')(tailwindConfig);
|
131
|
+
}
|
58
132
|
|
59
|
-
|
133
|
+
};
|
134
|
+
}
|
60
135
|
});
|
61
136
|
|
62
137
|
exports.default = _default;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.template = exports.checkTwinMacroNotExist = void 0;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var _utils = require("@modern-js/utils");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
const template = configPath => `
|
15
|
+
function _interopRequireDefault(obj) {
|
16
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
17
|
+
}
|
18
|
+
const modernConfig = _interopRequireDefault(require('${configPath}')).default;
|
19
|
+
|
20
|
+
const theme =
|
21
|
+
modernConfig && modernConfig.source && modernConfig.source.designSystem
|
22
|
+
? modernConfig.source.designSystem
|
23
|
+
: {};
|
24
|
+
const tailwindcss =
|
25
|
+
modernConfig && modernConfig.tools && modernConfig.tools.tailwindcss
|
26
|
+
? modernConfig.tools.tailwindcss
|
27
|
+
: {};
|
28
|
+
|
29
|
+
module.exports = {
|
30
|
+
theme,
|
31
|
+
...tailwindcss,
|
32
|
+
};
|
33
|
+
`;
|
34
|
+
|
35
|
+
exports.template = template;
|
36
|
+
|
37
|
+
const checkTwinMacroNotExist = async appDirectory => {
|
38
|
+
const depName = 'twin.macro';
|
39
|
+
const packageJson = (await _utils.fs.readJSON(_path.default.join(appDirectory, 'package.json'), {
|
40
|
+
throws: false
|
41
|
+
})) || {};
|
42
|
+
|
43
|
+
if (typeof packageJson.dependencies === 'object' && packageJson.dependencies[depName] || typeof packageJson.devDependencies === 'object' && packageJson.devDependencies[depName]) {
|
44
|
+
return false;
|
45
|
+
}
|
46
|
+
|
47
|
+
return true;
|
48
|
+
};
|
49
|
+
|
50
|
+
exports.checkTwinMacroNotExist = checkTwinMacroNotExist;
|
package/dist/types/cli.d.ts
CHANGED
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.
|
14
|
+
"version": "1.3.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -32,19 +32,20 @@
|
|
32
32
|
}
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@babel/runtime": "^7",
|
36
|
-
"@modern-js/utils": "^1.7.
|
37
|
-
"@modern-js/plugin-design-token": "^1.0.
|
35
|
+
"@babel/runtime": "^7.18.0",
|
36
|
+
"@modern-js/utils": "^1.7.8",
|
37
|
+
"@modern-js/plugin-design-token": "^1.0.11"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@modern-js/core": "1.
|
40
|
+
"@modern-js/core": "1.12.1",
|
41
41
|
"@scripts/build": "0.0.0",
|
42
|
-
"@types/jest": "^
|
42
|
+
"@types/jest": "^27",
|
43
43
|
"@types/node": "^14",
|
44
44
|
"@types/tailwindcss": "^2.2.1",
|
45
45
|
"typescript": "^4",
|
46
46
|
"tailwindcss": "^2.0.4",
|
47
47
|
"jest": "^27",
|
48
|
+
"postcss": "^8.4.14",
|
48
49
|
"@scripts/jest-config": "0.0.0"
|
49
50
|
},
|
50
51
|
"peerDependencies": {
|
@@ -55,11 +56,34 @@
|
|
55
56
|
"registry": "https://registry.npmjs.org/",
|
56
57
|
"access": "public"
|
57
58
|
},
|
59
|
+
"wireit": {
|
60
|
+
"build": {
|
61
|
+
"command": "modern build",
|
62
|
+
"files": [
|
63
|
+
"src/**/*",
|
64
|
+
"tsconfig.json",
|
65
|
+
"package.json"
|
66
|
+
],
|
67
|
+
"output": [
|
68
|
+
"dist/**/*"
|
69
|
+
]
|
70
|
+
},
|
71
|
+
"test": {
|
72
|
+
"command": "jest --passWithNoTests",
|
73
|
+
"files": [
|
74
|
+
"src/**/*",
|
75
|
+
"tsconfig.json",
|
76
|
+
"package.json",
|
77
|
+
"tests/**/*"
|
78
|
+
],
|
79
|
+
"output": []
|
80
|
+
}
|
81
|
+
},
|
58
82
|
"scripts": {
|
59
83
|
"new": "modern new",
|
60
84
|
"dev": "modern build --watch",
|
61
|
-
"build": "
|
62
|
-
"test": "
|
85
|
+
"build": "wireit",
|
86
|
+
"test": "wireit"
|
63
87
|
},
|
64
88
|
"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"
|
65
89
|
}
|
package/.eslintrc.js
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
root: true,
|
3
|
-
extends: ['@modern-js'],
|
4
|
-
parserOptions: {
|
5
|
-
// the base path used to search for `tsconfig.json`
|
6
|
-
tsconfigRootDir: __dirname,
|
7
|
-
// the relative path to sub-package's `tsconfig.json`
|
8
|
-
project: ['./tsconfig.json'],
|
9
|
-
},
|
10
|
-
};
|
package/jest.config.js
DELETED
package/modern.config.js
DELETED