diff --git a/components/ng-zorro-antd.compact.less b/components/ng-zorro-antd.compact.less new file mode 100644 index 00000000000..cbca1626356 --- /dev/null +++ b/components/ng-zorro-antd.compact.less @@ -0,0 +1,3 @@ +@import "./style/compact.less"; +@import "./style/entry.less"; +@import "./components.less"; diff --git a/components/ng-zorro-antd.dark.less b/components/ng-zorro-antd.dark.less new file mode 100644 index 00000000000..9e5bcd9f8e5 --- /dev/null +++ b/components/ng-zorro-antd.dark.less @@ -0,0 +1,3 @@ +@import "./style/dark.less"; +@import "./style/entry.less"; +@import "./components.less"; diff --git a/docs/customize-theme.en-US.md b/docs/customize-theme.en-US.md index 15a71c22b3e..83e934a8a14 100644 --- a/docs/customize-theme.en-US.md +++ b/docs/customize-theme.en-US.md @@ -131,12 +131,11 @@ We have some official themes, try them out and give us some feedback! ### Method 1 -include `ng-zorro-antd/style/dark.less` or `ng-zorro-antd/style/compact.less` in the style file to override theme variables. +Import `ng-zorro-antd.dark.less` or `ng-zorro-antd.compact.less` in the style file. ```less -@import "ng-zorro-antd/ng-zorro-antd.less"; -@import "~ng-zorro-antd/style/dark.less"; // Introduce the official dark less style file -@import "~ng-zorro-antd/style/compact.less"; // Introduce the official compact less style file +@import "~ng-zorro-antd/ng-zorro-antd.dark.less"; // Introduce the official dark less style file +@import "~ng-zorro-antd/ng-zorro-antd.compact.less"; // Introduce the official compact less style file ``` ### Method 2 diff --git a/docs/customize-theme.zh-CN.md b/docs/customize-theme.zh-CN.md index 4bf744580c4..73e9198b0ad 100644 --- a/docs/customize-theme.zh-CN.md +++ b/docs/customize-theme.zh-CN.md @@ -131,12 +131,11 @@ module.exports = { ### 方式一 -是在样式文件引入 `ng-zorro-antd/style/dark.less` 或 `ng-zorro-antd/style/compact.less` 覆盖主题变量。 +是在样式文件全量引入 `ng-zorro-antd.dark.less` 或 `ng-zorro-antd.compact.less` 覆盖主题变量。 ```less -@import "ng-zorro-antd/ng-zorro-antd.less"; -@import "~ng-zorro-antd/style/dark.less"; // 引入官方提供的暗色 less 样式文件 -@import "~ng-zorro-antd/style/compact.less"; // 引入官方提供的紧凑 less 样式文件 +@import "~ng-zorro-antd/ng-zorro-antd.dark.less"; // 引入官方提供的暗色 less 样式文件 +@import "~ng-zorro-antd/ng-zorro-antd.compact.less"; // 引入官方提供的紧凑 less 样式文件 ``` ### 方式二 diff --git a/scripts/build/compile-styles.ts b/scripts/build/compile-styles.ts index e772cafc239..a26a628515e 100644 --- a/scripts/build/compile-styles.ts +++ b/scripts/build/compile-styles.ts @@ -27,12 +27,12 @@ function compileLess(content: string, savePath: string, min: boolean, sub?: bool } return less - .render(content, lessOptions) - .then(({ css }) => { - fs.writeFileSync(savePath, css); - resolve(); - }) - .catch(err => reject(err)); + .render(content, lessOptions) + .then(({ css }) => { + fs.writeFileSync(savePath, css); + resolve(); + }) + .catch(err => reject(err)); }); } @@ -50,20 +50,24 @@ export function compile(): Promise { // Compile less files to CSS and delete the `entry.less` file. const buildFilePath = `${sourcePath}/${dir}/style/entry.less`; if (fs.existsSync(buildFilePath)) { - promiseList.push(compileLess( - fs.readFileSync(buildFilePath, { encoding: 'utf8' }), - path.join(targetPath, dir, 'style', `index.css`), - false, - true, - buildFilePath - )); - promiseList.push(compileLess( - fs.readFileSync(buildFilePath, { encoding: 'utf8' }), - path.join(targetPath, dir, 'style', `index.min.css`), - true, - true, - buildFilePath - )); + promiseList.push( + compileLess( + fs.readFileSync(buildFilePath, { encoding: 'utf8' }), + path.join(targetPath, dir, 'style', `index.css`), + false, + true, + buildFilePath + ) + ); + promiseList.push( + compileLess( + fs.readFileSync(buildFilePath, { encoding: 'utf8' }), + path.join(targetPath, dir, 'style', `index.min.css`), + true, + true, + buildFilePath + ) + ); } } }); @@ -72,6 +76,8 @@ export function compile(): Promise { fs.copySync(path.resolve(sourcePath, 'style'), path.resolve(targetPath, 'style')); fs.writeFileSync(`${targetPath}/components.less`, fs.readFileSync(`${sourcePath}/components.less`)); fs.writeFileSync(`${targetPath}/ng-zorro-antd.less`, fs.readFileSync(`${sourcePath}/ng-zorro-antd.less`)); + fs.writeFileSync(`${targetPath}/ng-zorro-antd.dark.less`, fs.readFileSync(`${sourcePath}/ng-zorro-antd.dark.less`)); + fs.writeFileSync(`${targetPath}/ng-zorro-antd.compact.less`, fs.readFileSync(`${sourcePath}/ng-zorro-antd.compact.less`)); // Compile concentrated less file to CSS file. const lessContent = `@import "${path.posix.join(targetPath, 'ng-zorro-antd.less')}";`; @@ -79,14 +85,12 @@ export function compile(): Promise { promiseList.push(compileLess(lessContent, path.join(targetPath, 'ng-zorro-antd.min.css'), true)); // Compile the dark theme less file to CSS file. - const darkLessContent = `@import "${path.posix.join(targetPath, 'style', 'dark.less')}"; - @import "${path.posix.join(targetPath, 'ng-zorro-antd.less')}";`; + const darkLessContent = `@import "${path.posix.join(targetPath, 'ng-zorro-antd.dark.less')}";`; promiseList.push(compileLess(darkLessContent, path.join(targetPath, 'ng-zorro-antd.dark.css'), false)); promiseList.push(compileLess(darkLessContent, path.join(targetPath, 'ng-zorro-antd.dark.min.css'), true)); // Compile the compact theme less file to CSS file. - const compactLessContent = `@import "${path.posix.join(targetPath, 'style', 'compact.less')}"; - @import "${path.posix.join(targetPath, 'ng-zorro-antd.less')}";`; + const compactLessContent = `@import "${path.posix.join(targetPath, 'ng-zorro-antd.compact.less')}";`; promiseList.push(compileLess(compactLessContent, path.join(targetPath, 'ng-zorro-antd.compact.css'), false)); promiseList.push(compileLess(compactLessContent, path.join(targetPath, 'ng-zorro-antd.compact.min.css'), true)); @@ -95,5 +99,5 @@ export function compile(): Promise { const cssIndex = fs.readFileSync(cssIndexPath, { encoding: 'utf8' }); promiseList.push(compileLess(cssIndex, path.join(targetPath, 'style', 'index.css'), false, true, cssIndexPath)); promiseList.push(compileLess(cssIndex, path.join(targetPath, 'style', 'index.min.css'), true, true, cssIndexPath)); - return Promise.all(promiseList).catch(e => console.log(e)) + return Promise.all(promiseList).catch(e => console.log(e)); }