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

86 lines
1.9 KiB

1 week ago
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const {
VueLoaderPlugin
} = require('vue-loader')
1 week ago
module.exports = {
mode: 'production',
entry: {
1 week ago
'zhicheng-components': './packages/index.js'
1 week ago
},
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].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: [MiniCssExtractPlugin.loader, 'css-loader'] // 替换style-loader
1 week ago
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
use: [{
loader: 'url-loader',
options: {
limit: 4096,
name: 'fonts/[name].[hash:8].[ext]',
esModule: false,
publicPath: '../', // 关键:修正 CSS 中的引用路径
}
}]
},
{
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(),
new MiniCssExtractPlugin({
filename: 'css/[name].css' // 输出到dist/css/
})
1 week ago
],
optimization: {
splitChunks: false
},
1 week ago
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
}
}