mirror of https://github.com/harness/drone.git
Optimize webpack configs + Upgrade UICore to 4.1.1 (#1220)
parent
650b6ba7df
commit
0861c9aa04
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const packageJSON = require('../package.json')
|
const packageJSON = require('../package.json')
|
||||||
const { pick, omit, mapValues } = require('lodash')
|
const { pick, mapValues } = require('lodash')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These packages must be stricly shared with exact versions
|
* These packages must be stricly shared with exact versions
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const webpack = require('webpack')
|
|
||||||
const {
|
const {
|
||||||
container: { ModuleFederationPlugin },
|
container: { ModuleFederationPlugin },
|
||||||
DefinePlugin
|
DefinePlugin
|
||||||
} = require('webpack')
|
} = require('webpack')
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
|
const HTMLWebpackPlugin = require('html-webpack-plugin')
|
||||||
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
|
||||||
const GenerateStringTypesPlugin = require('../scripts/webpack/GenerateStringTypesPlugin').GenerateStringTypesPlugin
|
const GenerateStringTypesPlugin = require('../scripts/webpack/GenerateStringTypesPlugin').GenerateStringTypesPlugin
|
||||||
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin')
|
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin')
|
||||||
|
@ -42,9 +42,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
publicPath: 'auto',
|
publicPath: 'auto',
|
||||||
filename: DEV ? 'static/[name].js' : 'static/[name].[contenthash:6].js',
|
pathinfo: false,
|
||||||
chunkFilename: DEV ? 'static/[name].[id].js' : 'static/[name].[id].[contenthash:6].js',
|
filename: '[name].[contenthash:6].js',
|
||||||
pathinfo: false
|
chunkFilename: '[name].[id].[contenthash:6].js'
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -168,6 +168,17 @@ module.exports = {
|
||||||
loader: 'file-loader'
|
loader: 'file-loader'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.md$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'raw-loader',
|
||||||
|
options: {
|
||||||
|
esModule: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -176,6 +187,18 @@ module.exports = {
|
||||||
plugins: [new TsconfigPathsPlugin()]
|
plugins: [new TsconfigPathsPlugin()]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
ignoreOrder: true,
|
||||||
|
filename: '[name].[contenthash:6].css',
|
||||||
|
chunkFilename: '[name].[id].[contenthash:6].css'
|
||||||
|
}),
|
||||||
|
new HTMLWebpackPlugin({
|
||||||
|
template: 'src/index.html',
|
||||||
|
filename: 'index.html',
|
||||||
|
favicon: 'src/favicon.svg',
|
||||||
|
minify: false,
|
||||||
|
templateParameters: {}
|
||||||
|
}),
|
||||||
new ModuleFederationPlugin(moduleFederationConfig),
|
new ModuleFederationPlugin(moduleFederationConfig),
|
||||||
new DefinePlugin({
|
new DefinePlugin({
|
||||||
'process.env': '{}', // required for @blueprintjs/core
|
'process.env': '{}', // required for @blueprintjs/core
|
||||||
|
|
|
@ -15,26 +15,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const util = require('util')
|
|
||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
|
|
||||||
const { merge } = require('webpack-merge')
|
const { merge } = require('webpack-merge')
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
||||||
const HTMLWebpackPlugin = require('html-webpack-plugin')
|
|
||||||
const {
|
|
||||||
DefinePlugin,
|
|
||||||
WatchIgnorePlugin,
|
|
||||||
container: { ModuleFederationPlugin }
|
|
||||||
} = require('webpack')
|
|
||||||
|
|
||||||
const commonConfig = require('./webpack.common')
|
const commonConfig = require('./webpack.common')
|
||||||
|
|
||||||
const API_URL = process.env.API_URL ?? 'http://localhost:3000'
|
const API_URL = process.env.API_URL ?? 'http://localhost:3000'
|
||||||
const HOST = 'localhost'
|
const HOST = 'localhost'
|
||||||
const PORT = process.env.PORT ?? 3020
|
const PORT = process.env.PORT ?? 3020
|
||||||
const STANDALONE = JSON.parse(process.env.STANDALONE ?? 'true')
|
const STANDALONE = JSON.parse(process.env.STANDALONE ?? 'true')
|
||||||
|
const CONTEXT = process.cwd()
|
||||||
|
|
||||||
console.info(`Starting development build... http://${HOST}:${PORT}`)
|
console.info(`Starting development build... http://${HOST}:${PORT}`)
|
||||||
console.info('Environment variables:')
|
console.info('Environment variables:')
|
||||||
|
@ -42,16 +33,10 @@ console.table({ STANDALONE, HOST, PORT, API_URL })
|
||||||
|
|
||||||
const devConfig = {
|
const devConfig = {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
target: 'web',
|
context: CONTEXT,
|
||||||
entry: './src/index.tsx',
|
entry: path.resolve(CONTEXT, '/src/index.tsx'),
|
||||||
devtool: 'cheap-module-source-map',
|
devtool: 'cheap-module-source-map',
|
||||||
cache: { type: 'filesystem' },
|
cache: { type: 'filesystem' },
|
||||||
output: {
|
|
||||||
filename: '[name].js',
|
|
||||||
chunkFilename: '[name].[id].js',
|
|
||||||
path: path.resolve(process.cwd(), 'dist'),
|
|
||||||
pathinfo: false
|
|
||||||
},
|
|
||||||
...(STANDALONE
|
...(STANDALONE
|
||||||
? {
|
? {
|
||||||
optimization: {
|
optimization: {
|
||||||
|
@ -75,43 +60,6 @@ const devConfig = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
compress: false
|
compress: false
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
filename: '[name].css',
|
|
||||||
chunkFilename: '[name].[id].css',
|
|
||||||
ignoreOrder: true
|
|
||||||
}),
|
|
||||||
new HTMLWebpackPlugin({
|
|
||||||
publicPath: '/',
|
|
||||||
template: 'src/index.html',
|
|
||||||
filename: 'index.html',
|
|
||||||
favicon: 'src/favicon.svg',
|
|
||||||
minify: false,
|
|
||||||
templateParameters: {
|
|
||||||
__DEV__: true
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new DefinePlugin({
|
|
||||||
'process.env': '{}', // required for @blueprintjs/core
|
|
||||||
__DEV__: true,
|
|
||||||
__ENABLE_CDN__: false
|
|
||||||
})
|
|
||||||
],
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.md$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'raw-loader',
|
|
||||||
options: {
|
|
||||||
esModule: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,23 +15,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { merge } = require('webpack-merge')
|
const { merge } = require('webpack-merge')
|
||||||
const path = require('path')
|
|
||||||
const HTMLWebpackPlugin = require('html-webpack-plugin')
|
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
||||||
const { DefinePlugin } = require('webpack')
|
|
||||||
|
|
||||||
const commonConfig = require('./webpack.common')
|
const commonConfig = require('./webpack.common')
|
||||||
const CONTEXT = process.cwd()
|
const CONTEXT = process.cwd()
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const prodConfig = {
|
const prodConfig = {
|
||||||
context: CONTEXT,
|
context: CONTEXT,
|
||||||
entry: path.resolve(CONTEXT, '/src/index.tsx'),
|
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
|
entry: path.resolve(CONTEXT, '/src/index.tsx'),
|
||||||
devtool: process.env.ENABLE_SOURCE_MAP ? 'source-map' : false,
|
devtool: process.env.ENABLE_SOURCE_MAP ? 'source-map' : false,
|
||||||
output: {
|
|
||||||
filename: '[name].[contenthash:6].js',
|
|
||||||
chunkFilename: '[name].[id].[contenthash:6].js'
|
|
||||||
},
|
|
||||||
optimization: {
|
optimization: {
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
chunks: 'all',
|
chunks: 'all',
|
||||||
|
@ -51,21 +43,7 @@ const prodConfig = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
plugins: [
|
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
ignoreOrder: true,
|
|
||||||
filename: '[name].[contenthash:6].css',
|
|
||||||
chunkFilename: '[name].[id].[contenthash:6].css'
|
|
||||||
}),
|
|
||||||
new HTMLWebpackPlugin({
|
|
||||||
template: 'src/index.html',
|
|
||||||
filename: 'index.html',
|
|
||||||
favicon: 'src/favicon.svg',
|
|
||||||
minify: false,
|
|
||||||
templateParameters: {}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = merge(commonConfig, prodConfig)
|
module.exports = merge(commonConfig, prodConfig)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
"@codemirror/view": "^6.9.6",
|
"@codemirror/view": "^6.9.6",
|
||||||
"@harnessio/design-system": "^2.1.1",
|
"@harnessio/design-system": "^2.1.1",
|
||||||
"@harnessio/icons": "^2.1.0",
|
"@harnessio/icons": "^2.1.0",
|
||||||
"@harnessio/uicore": "^4.1.0",
|
"@harnessio/uicore": "^4.1.1",
|
||||||
"@types/dompurify": "^3.0.2",
|
"@types/dompurify": "^3.0.2",
|
||||||
"@types/react-monaco-editor": "^0.16.0",
|
"@types/react-monaco-editor": "^0.16.0",
|
||||||
"@uiw/codemirror-extensions-color": "^4.19.9",
|
"@uiw/codemirror-extensions-color": "^4.19.9",
|
||||||
|
|
|
@ -1640,10 +1640,10 @@
|
||||||
resolved "https://registry.npmjs.org/@harnessio/icons/-/icons-2.1.0.tgz#9d93d5a4080e76d4f1b435ca2d28266d0ba936d0"
|
resolved "https://registry.npmjs.org/@harnessio/icons/-/icons-2.1.0.tgz#9d93d5a4080e76d4f1b435ca2d28266d0ba936d0"
|
||||||
integrity sha512-9DFu0v+Q0nx2HeJb7lWaWA6lnokSPcAKnjBDi87BWaY6SXbCn8Tk5wqWSnv/V2Xmn05iN89hjnuAjOhTuSpxXA==
|
integrity sha512-9DFu0v+Q0nx2HeJb7lWaWA6lnokSPcAKnjBDi87BWaY6SXbCn8Tk5wqWSnv/V2Xmn05iN89hjnuAjOhTuSpxXA==
|
||||||
|
|
||||||
"@harnessio/uicore@^4.1.0":
|
"@harnessio/uicore@^4.1.1":
|
||||||
version "4.1.0"
|
version "4.1.1"
|
||||||
resolved "https://registry.npmjs.org/@harnessio/uicore/-/uicore-4.1.0.tgz#e7b18ce59ddbde07441b9a5da8250b0cdd35f91e"
|
resolved "https://registry.npmjs.org/@harnessio/uicore/-/uicore-4.1.1.tgz#958e7109489d7551fa3b6a01cbd2286479c61701"
|
||||||
integrity sha512-NUJt5ZD3PP55QR9mLhvRCn2uUhy18uY+Lv9z5J37Hoc+e5DVtnp6FG/ZNvqPpSXnnvQ3bFGElf8AD4bJmIs9Hg==
|
integrity sha512-uR88UW+ZN8n9yzxTnGp4bmmdR6eJacgsBfW5K3N7WQ3ISAmMB09842w2Y6sFiDUD8+RB4UqlOuBrjVUmrZroVg==
|
||||||
|
|
||||||
"@humanwhocodes/config-array@^0.5.0":
|
"@humanwhocodes/config-array@^0.5.0":
|
||||||
version "0.5.0"
|
version "0.5.0"
|
||||||
|
|
Loading…
Reference in New Issue