-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const nodeExternals = require('webpack-node-externals'); | ||
const Components = require('../components.json'); | ||
|
||
let externals = {}; | ||
|
||
Object.keys(Components).forEach((key) => { | ||
externals[`element-pro-crud/src/component/${key}`] = `element-pro-crud/lib/${key}`; | ||
}); | ||
|
||
externals = [ | ||
Object.assign( | ||
{ | ||
vue: 'vue', | ||
}, | ||
externals, | ||
), | ||
nodeExternals(), | ||
]; | ||
|
||
exports.externals = externals; | ||
|
||
exports.alias = { | ||
'@': path.resolve(__dirname, '../src'), | ||
}; | ||
|
||
exports.vue = { | ||
root: 'Vue', | ||
commonjs: 'vue', | ||
commonjs2: 'vue', | ||
amd: 'vue', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
const path = require('path'); | ||
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | ||
const VueLoaderPlugin = require('vue-loader/lib/plugin'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); | ||
const webpack = require('webpack'); | ||
const Components = require('../components.json'); | ||
const config = require('./config'); | ||
const { name, version, author, homepage } = require('../package'); | ||
|
||
const webpackConfig = { | ||
mode: 'production', | ||
entry: Components, | ||
output: { | ||
path: path.resolve(process.cwd(), 'lib'), | ||
publicPath: '/dist/', | ||
filename: '[name].umd.min.js', | ||
chunkFilename: '[id].js', | ||
libraryTarget: 'umd', | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js', '.vue', '.json'], | ||
alias: config.alias, | ||
modules: ['node_modules'], | ||
}, | ||
// 排除部分依赖不进行打包 | ||
externals: config.externals, | ||
// 允许打包250kb以上的资源 | ||
performance: { | ||
hints: false, | ||
}, | ||
stats: 'none', | ||
optimization: { | ||
minimize: true, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
options: { | ||
compilerOptions: { | ||
preserveWhitespace: false, | ||
}, | ||
}, | ||
}, | ||
{ test: /\.ts?$/, loader: 'ts-loader', exclude: /node_modules/ }, | ||
{ | ||
test: /\.(js?|babel|es6)$/, | ||
include: process.cwd(), | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}, | ||
{ | ||
test: /\.(scss|css)$/, | ||
loaders: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'], | ||
}, | ||
{ | ||
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/, | ||
loader: 'url-loader', | ||
query: { | ||
limit: 10000, | ||
name: path.posix.join('static', '[name].[hash:7].[ext]'), | ||
}, | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new VueLoaderPlugin(), | ||
new MiniCssExtractPlugin({ | ||
filename: '[name].css', | ||
}), | ||
new ProgressBarPlugin(), | ||
new BundleAnalyzerPlugin({ | ||
analyzerMode: 'static', | ||
}), | ||
new webpack.BannerPlugin({ | ||
entryOnly: true, // 是否仅在入口包中输出 banner 信息 | ||
// eslint-disable-next-line no-useless-concat | ||
banner: () => `${name} v${version}` + '\n' + `Author: ${author}` + '\n' + `Documentation: ${homepage}` + '\n' + `Date: ${new Date()}`, | ||
}), | ||
], | ||
}; | ||
|
||
module.exports = webpackConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"pro-crud":"/src/index.ts", | ||
"pro-form": "./src/component/pro-form/index.ts", | ||
"pro-table": "./src/component/pro-table/index.ts", | ||
"crud-table": "./src/component/crud-table/index.ts", | ||
"form-designer": "./src/component/form-designer/index.ts", | ||
"table-designer": "./src/component/table-designer/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters