You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

94 lines
3.0 KiB

/**
* platform-core 库构建
*/
const path = require('path'); // path
const { merge } = require('webpack-merge'); // webpack 配置合并函数
const common = require('./webpack.config.common.cjs'); // webpack 通用配置
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 抽取 css 插件
const config = merge(common, {
mode: 'production',
entry: {
'platform-core': './src/platform/index.ts',
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
library: {
name: {
root: '[name]',
amd: '[name]',
commonjs: '[name]',
},
type: 'umd',
},
clean: true,
},
// 外部化第三方库, 仅打包 platform-core 库
externals: [
{
'@codemirror/autocomplete': '@codemirror/autocomplete',
'@codemirror/commands': '@codemirror/commands',
'@codemirror/lang-html': '@codemirror/lang-html',
'@codemirror/lang-java': '@codemirror/lang-java',
'@codemirror/lang-javascript': '@codemirror/lang-javascript',
'@codemirror/lang-json': '@codemirror/lang-json',
'@codemirror/lang-sql': '@codemirror/lang-sql',
'@codemirror/lang-xml': '@codemirror/lang-xml',
'@codemirror/language': '@codemirror/language',
'@codemirror/search': '@codemirror/search',
'@codemirror/state': '@codemirror/state',
'@codemirror/view': '@codemirror/view',
'@maxgraph/core': '@maxgraph/core',
'@quasar/extras': '@quasar/extras',
'@univerjs/core': '@univerjs/core',
'@univerjs/design': '@univerjs/design',
'@univerjs/docs': '@univerjs/docs',
'@univerjs/docs-ui': '@univerjs/docs-ui',
'@univerjs/engine-formula': '@univerjs/engine-formula',
'@univerjs/engine-render': '@univerjs/engine-render',
'@univerjs/facade': '@univerjs/facade',
'@univerjs/sheets': '@univerjs/sheets',
'@univerjs/sheets-formula': '@univerjs/sheets-formula',
'@univerjs/sheets-ui': '@univerjs/sheets-ui',
'@univerjs/thread-comment':'@univerjs/thread-comment',
'@univerjs/ui': '@univerjs/ui',
'@vueuse/core': '@vueuse/core',
'axios': 'axios',
'codemirror': 'codemirror',
'dayjs': 'dayjs',
'echarts': 'echarts',
'exceljs': 'exceljs',
'file-saver': 'file-saver',
'luckyexcel': 'luckyexcel',
'mockjs': 'mockjs',
'pinia': 'pinia',
'quasar': 'quasar',
'svg-path-commander': 'svg-path-commander',
'vue': 'vue',
'vue-dompurify-html': 'vue-dompurify-html',
'vue-i18n': 'vue-i18n',
'vue-router': 'vue-router',
'xml-formatter': 'xml-formatter'
},
],
optimization: {
minimize: false,
moduleIds: 'named',
chunkIds: 'named',
},
});
// 修改 css 输出路径和名称
for (let i = 0; i < config.plugins.length; i++) {
const plugin = config.plugins[i];
if (plugin instanceof MiniCssExtractPlugin) {
plugin.options.filename = `css/[name].css`;
plugin.options.chunkFilename = `css/[name].css`;
}
}
module.exports = config;