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.
|
|
|
const path = require('path')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const {
|
|
|
|
VueLoaderPlugin
|
|
|
|
} = require('vue-loader')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: 'production',
|
|
|
|
entry: {
|
|
|
|
'zhicheng-components': './packages/index.js'
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, '../dist'),
|
|
|
|
filename: '[name].umd.js',
|
|
|
|
library: 'ZhichengUI',
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
umdNamedDefine: true,
|
|
|
|
globalObject: `(typeof self !== 'undefined' ? self : this)`
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './packages') // 确保别名指向正确
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
compilerOptions: {
|
|
|
|
preserveWhitespace: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader'] // 替换style-loader
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new VueLoaderPlugin(),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'css/[name].css' // 输出到dist/css/
|
|
|
|
})
|
|
|
|
],
|
|
|
|
optimization: {
|
|
|
|
splitChunks: false
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
vue: {
|
|
|
|
root: 'Vue',
|
|
|
|
commonjs: 'vue',
|
|
|
|
commonjs2: 'vue',
|
|
|
|
amd: 'vue'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|