0 Star 45 Fork 25

BNDong / Cnblogs-Theme-SimpleMemory

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 2.56 KB
一键复制 编辑 原始数据 按行查看 历史
BNDong 提交于 2021-05-06 17:35 . Init v2.0.0
const path = require('path');
const json5 = require('json5');
const terserPlugin = require("terser-webpack-plugin");
const fileManagerPlugin = require('filemanager-webpack-plugin');
const miniCssExtractPlugin = require('mini-css-extract-plugin');
const cssMinimizerPlugin = require('css-minimizer-webpack-plugin');
/**
* 随机字符串
* @param len
* @returns {string}
*/
function randomString(len) {
len = len || 32;
let $chars = 'abcdefhijkmnprstwxyz23456789';
let maxPos = $chars.length;
let pwd = '';
for (let i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
module.exports = {
mode: 'development',
entry: './src/main.js',
output: {
filename: 'simpleMemory.js',
chunkFilename:'script/[name].[hash:8].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
plugins: [
new fileManagerPlugin({
events: {
onEnd: {
copy: [
{ source: './dist/simpleMemory.js', destination: './dist/simpleMemory.' + randomString(8) + '.js' },
],
}
}
}),
new miniCssExtractPlugin({
filename: 'style/[name].[hash:8].css',
chunkFilename:'style/[name].[hash:8].css',
}),
],
// devtool: 'inline-source-map',
optimization: {
minimize: true,
minimizer: [
new terserPlugin({
extractComments: false,
}),
new cssMinimizerPlugin(),
],
},
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: miniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
},
'css-loader'
],
},
{
test: /\.(png|svg|jpg|jpeg|gif|webp)$/i,
type: 'asset/resource',
generator: {
filename: 'images/[hash][ext][query]'
}
},
{
test: /\.json5$/i,
type: 'json',
parser: {
parse: json5.parse,
},
},
{
test: /\.html$/i,
loader: 'html-loader',
options: {
minimize: true,
},
},
],
},
};
JavaScript
1
https://gitee.com/dbnuo/Cnblogs-Theme-SimpleMemory.git
git@gitee.com:dbnuo/Cnblogs-Theme-SimpleMemory.git
dbnuo
Cnblogs-Theme-SimpleMemory
Cnblogs-Theme-SimpleMemory
v2

搜索帮助