vue3+webpack5+vue-i18n国际版官网,支持多国语言中英法等语言切换,暗黑明亮主题风格切换,多页面应用框架,从0-100实现详细步骤说明

国际版官网框架

vue3+webpack5打包+vue-i18n国际化语言+element-plus组件库

1. 项目结构如下:

在这里插入图片描述

2. 主要用webpack5玩转多页面应用框架和单页面应用框架,多页面应用框架webpack.config.js配置如下:

const path = require("path");
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const {
   VueLoaderPlugin} = require('vue-loader');
const isProduction = process.env.NODE_ENV === 'production';
const {
    setEntry,setHtmlPlugin } = require('./webpack.util.js')
const {
    CleanWebpackPlugin } = require("clean-webpack-plugin");
const ESBuildPlugin = require('esbuild-webpack-plugin').default;

module.exports = () => {
   
  return {
   
    mode: isProduction ? "production" : "development",
    entry: setEntry,
    devtool: isProduction ? false : "inline-source-map",
    devServer: {
   
      open: true,
      hot: true, 
      port: 3001,
    },
    output: {
   
      path: path.resolve(__dirname, "./dist"),
      filename: "js/[name].[contenthash:10].js",
    },
    mode: isProduction ? 'production' : 'development',
    module: {
   
      rules: [
        {
   
          //.js文件loader
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
   
            loader: 'babel-loader',
            options: {
   
              cacheDirectory: true,
              cacheCompression: false
            }
          }
        },
        {
   
          //.vue文件loader
          test: /\.vue$/,
          use: 'vue-loader'   
        },
        {
   
          //.css文件loader
          test: /\.css$/,
          use: [isProduction ? MiniCssExtractPlugin.loader : 'vue-style-loader', 'css-loader']
        },
        {
    //图片
          test: /\.(png|svg|jpg|jpeg|gif|bmp)$/,
          type: 'asset/resource',
          generator:{
    
              filename: 'image/[contenthash:10].[ext]',
          }, 
        },
        {
   
          test: /\.mp4$/,
          use: {
   
            loader: 'file-loader',
            options: {
   
              name: 'video/[contenthash:10].[ext]',
            },
          },
        },
      ]
    },
    resolve: {
   // 设置模块如何被解析
      alias: {
   
        vue: "vue/dist/vue.esm-bundler.js"
      },
      extensions: ['.js', '.vue']// 按顺序解析这些后缀名
    },
    optimization: {
   
      minimizer: [new ESBuildPlugin()],
      splitChunks: {
   
        cacheGroups: {
   
          defaultVendors: {
   
            name: 'chunk-vendors',
            test: /[\\/]node_modules[\\/]/,
            priority: -10,
            chunks: 'initial'
          },
          common: {
   
            name
  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

为了WLB努力

给点小钱,你的鼓励是我坚持动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值