'use strict' const { join, resolve } = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin') const config = { mode: 'production', entry: './src/main.js', output: { path: resolve(__dirname, './docs'), filename: 'main.js' }, resolve: { // 配置别名,在项目中可缩减引用路径 alias: { src: join(__dirname, '/src') } }, module: { rules: [ { test: /\.vue$/, use: 'vue-loader' }, { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ }, { test: /\.css$/, use: ['style-loader', 'css-loader'] }, { test: /\.html$/i, loader: 'html-loader', }, { test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/, exclude: /favicon\.png$/, use: [ { loader: 'url-loader', options: { limit: 10000 } } ] } ] }, plugins: [ new VueLoaderPlugin(), new HtmlWebpackPlugin({ template: './src/index.html', inject: 'body' }) ], devtool: '#eval-source-map' } module.exports = config