From 020c4ba7d03a8af119ffc6c5ca88d386cc16133c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Sat, 11 Sep 2021 13:28:25 +0800 Subject: [PATCH] fix: missing `default.css` (#32116) * chore: Add CI for compile * chore: Add missing compile file --- .antd-tools.config.js | 22 ++------------------- .github/workflows/test.yml | 40 ++++++++++++++++++++++++++++++++++++++ package.json | 2 +- tests/dekko/lib.test.js | 2 ++ 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/.antd-tools.config.js b/.antd-tools.config.js index 4fddb635f2..7a5bec3673 100644 --- a/.antd-tools.config.js +++ b/.antd-tools.config.js @@ -35,24 +35,6 @@ function finalizeCompile() { ); }); } - - // Create entry for babel plugin import - function patchEntry(styleEntry) { - if (fs.existsSync(styleEntry)) { - fs.writeFileSync( - path.join(styleEntry, 'style', 'index-default.less'), - [ - // Inject variable - '@root-entry-name: default;', - // Point to origin file - "@import './index';", - ].join('\n'), - ); - } - } - - patchEntry(path.join(process.cwd(), 'lib')); - patchEntry(path.join(process.cwd(), 'es')); } function buildThemeFile(theme, vars) { @@ -154,6 +136,7 @@ function needTransformStyle(content) { module.exports = { compile: { + includeLessFile: [/(\/|\\)components(\/|\\)style(\/|\\)default.less$/], transformTSFile(file) { if (isComponentStyleEntry(file)) { let content = file.contents.toString(); @@ -162,8 +145,7 @@ module.exports = { const cloneFile = file.clone(); // Origin - content = content.replace('../../style/index.less', '../../style/index-default.less'); - // content = content.replace('./index.less', './index-default.less'); + content = content.replace('../../style/index.less', '../../style/default.less'); cloneFile.contents = Buffer.from(content); return cloneFile; diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 84ff65ecf0..1100b3bc76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -453,4 +453,44 @@ jobs: run: npm test env: LIB_DIR: dist + needs: setup + + style: + name: style compile + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@master + + - name: restore cache from package-lock.json + uses: actions/cache@v2 + with: + path: package-temp-dir + key: lock-${{ github.sha }} + + - name: restore cache from node_modules + uses: actions/cache@v2 + with: + path: node_modules + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} + + - name: compile + run: npm run compile + + - name: dist + run: npm run dist + env: + NODE_OPTIONS: --max_old_space_size=4096 + + - name: lessc default + run: npx lessc --js ./dist/antd.less + + - name: lessc dark + run: npx lessc --js ./dist/antd.dark.less + + - name: lessc variable + run: npx lessc --js ./dist/antd.variable.less + + - name: lessc component + run: npx lessc --js ./es/button/style/index.less needs: setup \ No newline at end of file diff --git a/package.json b/package.json index 228498e5b3..33b7735a28 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "devDependencies": { "@ant-design/bisheng-plugin": "^2.3.0", "@ant-design/hitu": "^0.0.0-alpha.13", - "@ant-design/tools": "^14.0.0-alpha.2", + "@ant-design/tools": "^14.0.0-alpha.3", "@docsearch/css": "^3.0.0-alpha.39", "@docsearch/react": "^3.0.0-alpha.39", "@qixian.cs/github-contributors-list": "^1.0.3", diff --git a/tests/dekko/lib.test.js b/tests/dekko/lib.test.js index b7043ffa10..fb7be23135 100644 --- a/tests/dekko/lib.test.js +++ b/tests/dekko/lib.test.js @@ -8,6 +8,8 @@ function getFileName(filePath) { $('lib').isDirectory().hasFile('index.js').hasFile('index.d.ts'); +$('lib/style').isDirectory().hasFile('index.css').hasFile('default.css'); + $('lib/*') .filter( filename =>