Vue 教程(三十六)webpack 之代码混淆插件 Uglifyjs

时间:2025-03-26 07:34:20
// 导入Node中path常量 const path = require("path"); const webpack = require("webpack"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const UglifyjsWebpackPlugin = require("uglifyjs-webpack-plugin") module.exports = { entry: "./src/", output: { path: path.resolve(__dirname, 'dist'), filename: "", // publicPath: 'dist/' }, resolve: { // alias:别名 alias: { 'vue$': 'vue/dist/' } }, module: { rules: [ { test: /\.css$/, /** * css-loader:只负责将css文件进行加载 * style-loader:负责将样式添加到DOM中 * 使用多个loader时,是从右向左 */ use: ['style-loader', 'css-loader'] }, { test: /\.vue$/, use: ['vue-loader'] } ] }, plugins: [ new webpack.BannerPlugin("Copyright 2002-2021 the original author or under the Apache License, Version 2.0 (the 'License');"), new HtmlWebpackPlugin({ template: "" }), new UglifyjsWebpackPlugin() ] }