|
|
@ -61,11 +61,31 @@ function buildThemeFile(theme, vars) { |
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(`Built a entry less file to dist/antd.${theme}.less`); |
|
|
|
|
|
|
|
if (theme === 'default') { |
|
|
|
fs.writeFileSync( |
|
|
|
path.join(process.cwd(), 'dist', `default-theme.js`), |
|
|
|
`module.exports = ${JSON.stringify(vars, null, 2)};\n`, |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// Build ${theme}.js: dist/${theme}-theme.js, for less-loader
|
|
|
|
|
|
|
|
fs.writeFileSync( |
|
|
|
path.join(process.cwd(), 'dist', `theme.js`), |
|
|
|
`const ${theme}ThemeSingle = ${JSON.stringify(vars, null, 2)};\n`, |
|
|
|
{ |
|
|
|
flag: 'a', |
|
|
|
}, |
|
|
|
); |
|
|
|
|
|
|
|
fs.writeFileSync( |
|
|
|
path.join(process.cwd(), 'dist', `${theme}-theme.js`), |
|
|
|
`module.exports = ${JSON.stringify(vars, null, 2)};`, |
|
|
|
`const { ${theme}ThemeSingle } = require('./theme');\nconst defaultTheme = require('./default-theme');\n |
|
|
|
module.exports = { |
|
|
|
...${theme}ThemeSingle, |
|
|
|
...defaultTheme |
|
|
|
}`,
|
|
|
|
); |
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
@ -80,10 +100,46 @@ function finalizeDist() { |
|
|
|
'@import "../lib/style/index.less";\n@import "../lib/style/components.less";', |
|
|
|
); |
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
fs.writeFileSync( |
|
|
|
path.join(process.cwd(), 'dist', 'theme.js'), |
|
|
|
`const defaultTheme = require('./default-theme.js');\n`, |
|
|
|
); |
|
|
|
console.log('Built a entry less file to dist/antd.less'); |
|
|
|
buildThemeFile('default', defaultVars); |
|
|
|
buildThemeFile('dark', darkVars); |
|
|
|
buildThemeFile('compact', compactVars); |
|
|
|
fs.writeFileSync( |
|
|
|
path.join(process.cwd(), 'dist', `theme.js`), |
|
|
|
` |
|
|
|
function getThemeVariables(options = {}) { |
|
|
|
let themeVar = { |
|
|
|
'hack': \`true;@import "\${require.resolve('antd/lib/style/color/colorPalette.less')}";\`,
|
|
|
|
...defaultTheme |
|
|
|
}; |
|
|
|
if(options.dark) { |
|
|
|
themeVar = { |
|
|
|
...themeVar, |
|
|
|
...darkThemeSingle |
|
|
|
} |
|
|
|
} |
|
|
|
if(options.compact){ |
|
|
|
themeVar = { |
|
|
|
...themeVar, |
|
|
|
...compactThemeSingle |
|
|
|
} |
|
|
|
} |
|
|
|
return themeVar; |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
darkThemeSingle, |
|
|
|
compactThemeSingle, |
|
|
|
getThemeVariables |
|
|
|
}`,
|
|
|
|
{ |
|
|
|
flag: 'a', |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -95,3 +151,4 @@ module.exports = { |
|
|
|
finalize: finalizeDist, |
|
|
|
}, |
|
|
|
}; |
|
|
|
finalizeDist(); |
|
|
|