var path = require('path'); const { VueLoaderPlugin } = require('vue-loader'); const ESLintPlugin = require('eslint-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', }, { test: /\.js$/, loader: 'babel-loader', // include: [ // path.resolve(__dirname, './node_modules/pc-component-v3/dist/pc-component-v3.js'), // ], exclude: /node_modules/, // exclude: file => ( // /node_modules/.test(file) && // !/\.vue\.js/.test(file) // ), }, { test: /\.css$/, use: (process.env.NODE_ENV === 'production') ? [ { loader: MiniCssExtractPlugin.loader, options: { publicPath: '../', }, }, 'css-loader'] : ['style-loader', 'css-loader'], }, { test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files type: 'javascript/auto', loader: '@intlify/vue-i18n-loader', }, { // webpack5 通过资源模块来处理图片 test: /\.(png|jpg|gif|svg)$/, type: 'asset/resource', parser: { dataUrlCondition: { maxSize: 10240, }, }, generator: { filename: './client-eam-v5-image/[name][ext][query]', }, }, { test: /\.(eot|woff|woff2|ttf)$/, type: 'asset/resource', generator: { filename: './client-eam-v5-font/[name].[ext]?[hash]', }, }, ], }, resolve: { alias: { }, extensions: ['*', '.js', '.vue', '.json'], }, performance: { hints: false, }, externals: { 'jquery': "window.jquery", 'bootstrap': 'bootstrap', 'BootstrapDialog': 'BootstrapDialog', 'dayjs': 'dayjs', 'vue': 'Vue', 'vue-i18n': 'VueI18n', 'vue-router': 'VueRouter', 'vuex': 'Vuex', }, plugins: [ new VueLoaderPlugin(), new ESLintPlugin({ extensions: ['js', 'vue'], // 自动修复。 // 自从eslint推出--fix命令后,如果觉得eslint格式化规则已经够用的话,其实也可以不用prettier了。 fix: true, }), ], };