加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.js 2.87 KB
一键复制 编辑 原始数据 按行查看 历史
novel 提交于 2020-03-20 17:14 . 删除无用的开发引用。
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const devMode = 'production';//development production
module.exports = {
devtool: false,
mode: devMode,
entry: {
'main': "./src/main.js",
'index': './src/index.js'
},
output: {
path: path.resolve(__dirname, './dist/'),
filename: '[name].js',
library: 'eIconPicker',
libraryTarget: 'umd',
umdNamedDefine: true
},
resolve: {
extensions: ['.js', '.vue'],
},
module: {
rules: [
{
test: /\.vue$/,
use: [
'vue-loader'
]
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
}
,
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
require('postcss-import')(),
require('autoprefixer')()
]
}
}
],
},
{
test: /\.(gif|png|jpg|woff|svg|ttf|eot)\??.*$/,
use: [
{
loader: 'file-loader',
options: {
esModule: false, // 这里设置为false
outputPath: 'fonts',
name: '[name].[ext]'
}
}
]
}
]
},
optimization: {
runtimeChunk: false
},
plugins: [
new CleanWebpackPlugin(),
// 请确保引入这个插件!
new VueLoaderPlugin(),
//参数是一个数组,数组中是需要删除的目录名
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', {
discardComments: {
removeAll: true,
},
normalizeUnicode: false
}]
},
canPrint: true
})
]
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化