公共组件、公共样式集合
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.

83 lines
1.7 KiB

1 week ago
const path = require('path')
const {
VueLoaderPlugin
} = require('vue-loader')
1 week ago
module.exports = {
mode: 'production',
entry: {
'my-components': './packages/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
filename: 'zhicheng-components.umd.js',
library: 'ZhichengUI',
1 week ago
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: `(typeof self !== 'undefined' ? self : this)`
},
resolve: {
alias: {
'@': path.resolve(__dirname, './packages') // 确保别名指向正确
}
1 week ago
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false
}
}
1 week ago
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
use: [{
loader: 'url-loader',
options: {
limit: 4096, // 4KB 以下转为 base64
name: 'fonts/[name].[hash:8].[ext]',
esModule: false // 避免 __webpack_require__.n 问题
}
}]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
use: [{
loader: 'url-loader',
options: {
limit: 4096,
name: 'img/[name].[hash:8].[ext]',
esModule: false
}
}]
1 week ago
}
]
},
plugins: [
new VueLoaderPlugin()
],
optimization: {
splitChunks: {
chunks: 'all'
}
},
1 week ago
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
}
}