mirror of
https://github.com/youzan/vant.git
synced 2026-01-30 01:02:04 +08:00
feat(cli): build package
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import sass from 'sass';
|
||||
// @ts-ignore
|
||||
import FriendlyErrorsPlugin from '@nuxt/friendly-errors-webpack-plugin';
|
||||
import { VueLoaderPlugin } from 'vue-loader';
|
||||
import { POSTCSS_CONFIG_FILE } from '../common/constant';
|
||||
|
||||
@@ -16,7 +17,7 @@ const CSS_LOADERS = [
|
||||
}
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
export const baseConfig = {
|
||||
mode: 'development',
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.tsx', '.jsx', '.vue', '.less']
|
||||
@@ -72,7 +73,11 @@ module.exports = {
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [new VueLoaderPlugin()]
|
||||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new FriendlyErrorsPlugin({
|
||||
clearConsole: false,
|
||||
logLevel: 'WARNING'
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
export default module.exports;
|
||||
|
||||
39
packages/vant-cli/src/config/webpack.package.ts
Normal file
39
packages/vant-cli/src/config/webpack.package.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { join } from 'path';
|
||||
import merge from 'webpack-merge';
|
||||
import { baseConfig } from './webpack.base';
|
||||
import { LIB_DIR, DIST_DIR, CONFIG_FILE } from '../common/constant';
|
||||
|
||||
// eslint-disable-next-line
|
||||
const config = require(CONFIG_FILE);
|
||||
const { name } = config;
|
||||
|
||||
export function packageConfig(isMinify: boolean) {
|
||||
return merge(baseConfig as any, {
|
||||
mode: 'production',
|
||||
entry: {
|
||||
[name]: join(DIST_DIR, 'index.js')
|
||||
},
|
||||
stats: 'none',
|
||||
output: {
|
||||
path: LIB_DIR,
|
||||
library: name,
|
||||
libraryTarget: 'umd',
|
||||
filename: isMinify ? '[name].min.js' : '[name].js',
|
||||
umdNamedDefine: true,
|
||||
// https://github.com/webpack/webpack/issues/6522
|
||||
globalObject: "typeof self !== 'undefined' ? self : this"
|
||||
},
|
||||
externals: {
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
},
|
||||
performance: false,
|
||||
optimization: {
|
||||
minimize: isMinify
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import { join } from 'path';
|
||||
import merge from 'webpack-merge';
|
||||
import baseConfig from './webpack.base';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import { join } from 'path';
|
||||
import { baseConfig } from './webpack.base';
|
||||
import { CONFIG_FILE } from '../common/constant';
|
||||
|
||||
// eslint-disable-next-line
|
||||
const config = require(CONFIG_FILE);
|
||||
const title = `${config.title} - ${config.description}`;
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
export const siteDevConfig = merge(baseConfig as any, {
|
||||
entry: {
|
||||
'site-desktop': join(__dirname, '../../site/desktop/main.js'),
|
||||
'site-mobile': join(__dirname, '../../site/mobile/main.js')
|
||||
@@ -53,5 +53,3 @@ module.exports = merge(baseConfig, {
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
export default module.exports;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { join } from 'path';
|
||||
import merge from 'webpack-merge';
|
||||
import config from './webpack.site.dev';
|
||||
import { siteDevConfig } from './webpack.site.dev';
|
||||
|
||||
module.exports = merge(config, {
|
||||
export const sitePrdConfig = merge(siteDevConfig, {
|
||||
mode: 'production',
|
||||
output: {
|
||||
path: join(__dirname, '../../site/dist'),
|
||||
@@ -11,5 +11,3 @@ module.exports = merge(config, {
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js'
|
||||
}
|
||||
});
|
||||
|
||||
export default module.exports;
|
||||
|
||||
Reference in New Issue
Block a user