当前位置: 首页 > news >正文

Superset二次开发之webpack.config.js 功能模块解读

  • webpack.config.js 

 Webpack 构建工具的核心配置文件,它定义了如何处理项目中的源代码,包括编译、转换、合并、分包、压缩等多个环节。

 

/* eslint-disable no-console */
/*** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements.  See the NOTICE file* distributed with this work for additional information* regarding copyright ownership.  The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License.  You may obtain a copy of the License at**   http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing,* software distributed under the License is distributed on an* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY* KIND, either express or implied.  See the License for the* specific language governing permissions and limitations* under the License.*/
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const createMdxCompiler = require('@storybook/addon-docs/mdx-compiler-plugin');
const {WebpackManifestPlugin,getCompilerHooks,
} = require('webpack-manifest-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const parsedArgs = require('yargs').argv;
const getProxyConfig = require('./webpack.proxy-config');
const packageConfig = require('./package');// input dir
const APP_DIR = path.resolve(__dirname, './');
// output dir
const BUILD_DIR = path.resolve(__dirname, '../superset/static/assets');
const ROOT_DIR = path.resolve(__dirname, '..');const {mode = 'development',devserverPort = 9000,measure = false,analyzeBundle = false,analyzerPort = 8888,nameChunks = false,
} = parsedArgs;
const isDevMode = mode !== 'production';
const isDevServer = process.argv[1].includes('webpack-dev-server');
const ASSET_BASE_URL = process.env.ASSET_BASE_URL || '';const output = {path: BUILD_DIR,publicPath: `${ASSET_BASE_URL}/static/assets/`,
};
if (isDevMode) {output.filename = '[name].[contenthash:8].entry.js';output.chunkFilename = '[name].[contenthash:8].chunk.js';
} else if (nameChunks) {output.filename = '[name].[chunkhash].entry.js';output.chunkFilename = '[name].[chunkhash].chunk.js';
} else {output.filename = '[name].[chunkhash].entry.js';output.chunkFilename = '[chunkhash].chunk.js';
}if (!isDevMode) {output.clean = true;
}const plugins = [new webpack.ProvidePlugin({process: 'process/browser.js',}),// creates a manifest.json mapping of name to hashed output used in template filesnew WebpackManifestPlugin({publicPath: output.publicPath,seed: { app: 'superset' },// This enables us to include all relevant files for an entrygenerate: (seed, files, entrypoints) => {// Each entrypoint's chunk files in the format of// {//   entry: {//     css: [],//     js: []//   }// }const entryFiles = {};Object.entries(entrypoints).forEach(([entry, chunks]) => {entryFiles[entry] = {css: chunks.filter(x => x.endsWith('.css')).map(x => `${output.publicPath}${x}`),js: chunks.filter(x => x.endsWith('.js')).map(x => `${output.publicPath}${x}`),};});return {...seed,entrypoints: entryFiles,};},// Also write manifest.json to disk when running `npm run dev`.// This is required for Flask to work.writeToFileEmit: isDevMode && !isDevServer,}),// expose mode variable to other modulesnew webpack.DefinePlugin({'process.env.WEBPACK_MODE': JSON.stringify(mode),'process.env.REDUX_DEFAULT_MIDDLEWARE':process.env.REDUX_DEFAULT_MIDDLEWARE,}),new CopyPlugin({patterns: ['package.json',{ from: 'src/assets/images', to: 'i

相关文章:

  • 目标检测的相关模型图:YOLO系列和RCNN系列
  • 城市内涝排水系统最新模型:慧天【HTWATER】与SWMM完美耦合
  • 知乎:多云架构下大模型训练,如何保障存储稳定性?
  • C#学习笔记5:简单上位机串口助手的实现
  • MySQL---触发器
  • Webpack生成企业站静态页面 - 增强数据处理能力
  • Windows前后端部署(达梦,东方通)
  • 数据结构——双向链表
  • 利用图像识别进行疾病诊断
  • 【数据结构】顺序表的实现——静态分配
  • 气象预测新篇章:Python人工智能的变革力量
  • .helper勒索病毒的最新威胁:如何恢复您的数据?
  • 分类任务中的评估指标:Accuracy、Precision、Recall、F1
  • CUDA从入门到放弃(七):流( Streams)
  • ubuntu 不产生core dump 文件
  • 实现windows 窗体的自己画,网上摘抄的,学习了
  • 【162天】黑马程序员27天视频学习笔记【Day02-上】
  • 【css3】浏览器内核及其兼容性
  • 【跃迁之路】【641天】程序员高效学习方法论探索系列(实验阶段398-2018.11.14)...
  • Android开源项目规范总结
  • CentOS 7 防火墙操作
  • CSS居中完全指南——构建CSS居中决策树
  • E-HPC支持多队列管理和自动伸缩
  • ES6 学习笔记(一)let,const和解构赋值
  • ES6系列(二)变量的解构赋值
  • JavaScript 是如何工作的:WebRTC 和对等网络的机制!
  • JavaScript设计模式与开发实践系列之策略模式
  • java取消线程实例
  • PyCharm搭建GO开发环境(GO语言学习第1课)
  • socket.io+express实现聊天室的思考(三)
  • spring + angular 实现导出excel
  • vue-cli3搭建项目
  • vue-cli在webpack的配置文件探究
  • webpack4 一点通
  • win10下安装mysql5.7
  • 少走弯路,给Java 1~5 年程序员的建议
  • 设计模式走一遍---观察者模式
  • 使用API自动生成工具优化前端工作流
  • 听说你叫Java(二)–Servlet请求
  • 网络应用优化——时延与带宽
  • 文本多行溢出显示...之最后一行不到行尾的解决
  • 在 Chrome DevTools 中调试 JavaScript 入门
  • 从如何停掉 Promise 链说起
  • ​LeetCode解法汇总2182. 构造限制重复的字符串
  • ​LeetCode解法汇总2670. 找出不同元素数目差数组
  • ​LeetCode解法汇总2696. 删除子串后的字符串最小长度
  • ​软考-高级-信息系统项目管理师教程 第四版【第14章-项目沟通管理-思维导图】​
  • #我与Java虚拟机的故事#连载10: 如何在阿里、腾讯、百度、及字节跳动等公司面试中脱颖而出...
  • $NOIp2018$劝退记
  • ( 用例图)定义了系统的功能需求,它是从系统的外部看系统功能,并不描述系统内部对功能的具体实现
  • (C语言)二分查找 超详细
  • (pojstep1.1.1)poj 1298(直叙式模拟)
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)springboot家庭财务分析系统 毕业设计641323
  • (四)图像的%2线性拉伸