//生产环境配置 const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const VueLoaderPlugin = require('vue-loader/lib/plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); //清除文件夹 const CopyWebpackPlugin = require('copy-webpack-plugin'); //复制文件 const WebpackSftpClient = require('webpack-sftp-client'); //打包完成自动上传 module.exports = { mode: 'production', output: { path: path.resolve(__dirname, './../dist'), filename: 'js/[hash].min.js' }, plugins: [ new CopyWebpackPlugin([{ from: "src/public", to:"public" }]), new HtmlWebpackPlugin({ template: 'index.html', minify: { collapseWhitespace: true, //把生成的 index.html 文件的内容的没用空格去掉,减少空间 }, hash: true, //为了更好的 cache,可以在文件名后加个 hash。 }), new VueLoaderPlugin(), /*new WebpackSftpClient({ port: '22', //服务器端口 host: '172.16.90.253', //服务器地址 username: 'root', //用户名 password: 'hywa$123', //密码 path: path.resolve(__dirname, './../dist'), //本地路径 remotePath: '/www/演示项目/湄潭一期/ht-H5', //服务器上的路径 verbose: true }),*/ new CleanWebpackPlugin() ] }