chore(cli): extract create-vant-cli-app package
This commit is contained in:
@@ -13,91 +13,95 @@ import {
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
} from '../common/constant';
|
||||
|
||||
const vantConfig = getVantConfig();
|
||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||
export function getSiteDevBaseConfig() {
|
||||
const vantConfig = getVantConfig();
|
||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||
|
||||
function getSiteConfig() {
|
||||
const siteConfig = vantConfig.site;
|
||||
function getSiteConfig() {
|
||||
const siteConfig = vantConfig.site;
|
||||
|
||||
if (siteConfig.locales) {
|
||||
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
||||
}
|
||||
|
||||
return siteConfig;
|
||||
}
|
||||
|
||||
function getTitle(config: { title: string, description?: string }) {
|
||||
let { title } = config;
|
||||
|
||||
if (config.description) {
|
||||
title += ` - ${config.description}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
const siteConfig = getSiteConfig();
|
||||
const title = getTitle(siteConfig);
|
||||
|
||||
export const siteDevBaseConfig = merge(baseConfig as any, {
|
||||
entry: {
|
||||
'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
|
||||
'site-mobile': [join(__dirname, '../../site/mobile/main.js')]
|
||||
},
|
||||
devServer: {
|
||||
port: 8080,
|
||||
quiet: true,
|
||||
host: '0.0.0.0',
|
||||
stats: 'errors-only',
|
||||
publicPath: '/',
|
||||
disableHostCheck: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'site-mobile-shared': SITE_MODILE_SHARED_FILE,
|
||||
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE
|
||||
if (siteConfig.locales) {
|
||||
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
||||
}
|
||||
},
|
||||
output: {
|
||||
chunkFilename: '[name].js'
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
chunks: {
|
||||
chunks: 'all',
|
||||
minChunks: 2,
|
||||
minSize: 0,
|
||||
name: 'chunks'
|
||||
|
||||
return siteConfig;
|
||||
}
|
||||
|
||||
function getTitle(config: { title: string; description?: string }) {
|
||||
let { title } = config;
|
||||
|
||||
if (config.description) {
|
||||
title += ` - ${config.description}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
const siteConfig = getSiteConfig();
|
||||
const title = getTitle(siteConfig);
|
||||
|
||||
return merge(baseConfig as any, {
|
||||
entry: {
|
||||
'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
|
||||
'site-mobile': [join(__dirname, '../../site/mobile/main.js')]
|
||||
},
|
||||
devServer: {
|
||||
port: 8080,
|
||||
quiet: true,
|
||||
host: '0.0.0.0',
|
||||
stats: 'errors-only',
|
||||
publicPath: '/',
|
||||
disableHostCheck: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'site-mobile-shared': SITE_MODILE_SHARED_FILE,
|
||||
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE
|
||||
}
|
||||
},
|
||||
output: {
|
||||
chunkFilename: '[name].js'
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
chunks: {
|
||||
chunks: 'all',
|
||||
minChunks: 2,
|
||||
minSize: 0,
|
||||
name: 'chunks'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new WebpackBar({
|
||||
name: 'Vant Cli',
|
||||
color: GREEN
|
||||
}),
|
||||
new VantCliSitePlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
title,
|
||||
logo: siteConfig.logo,
|
||||
description: siteConfig.description,
|
||||
chunks: ['chunks', 'site-desktop'],
|
||||
template: join(__dirname, '../../site/desktop/index.html'),
|
||||
filename: 'index.html',
|
||||
baiduAnalytics
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title,
|
||||
logo: siteConfig.logo,
|
||||
description: siteConfig.description,
|
||||
chunks: ['chunks', 'site-mobile'],
|
||||
template: join(__dirname, '../../site/mobile/index.html'),
|
||||
filename: 'mobile.html',
|
||||
baiduAnalytics
|
||||
})
|
||||
]
|
||||
});
|
||||
},
|
||||
plugins: [
|
||||
new WebpackBar({
|
||||
name: 'Vant Cli',
|
||||
color: GREEN
|
||||
}),
|
||||
new VantCliSitePlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
title,
|
||||
logo: siteConfig.logo,
|
||||
description: siteConfig.description,
|
||||
chunks: ['chunks', 'site-desktop'],
|
||||
template: join(__dirname, '../../site/desktop/index.html'),
|
||||
filename: 'index.html',
|
||||
baiduAnalytics
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title,
|
||||
logo: siteConfig.logo,
|
||||
description: siteConfig.description,
|
||||
chunks: ['chunks', 'site-mobile'],
|
||||
template: join(__dirname, '../../site/mobile/index.html'),
|
||||
filename: 'mobile.html',
|
||||
baiduAnalytics
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export const siteDevConfig = merge(siteDevBaseConfig, getWebpackConfig());
|
||||
export function getSiteDevConfig() {
|
||||
return merge(getSiteDevBaseConfig(), getWebpackConfig());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user