0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 21:49:51 +01:00

chore: upgrade to Webpack 5 (#16648)

* chore: initial Webpack upgrade steps

* use over loaders

* include process

* add process package
This commit is contained in:
David Newell 2023-07-19 11:48:34 +01:00 committed by GitHub
parent 093476ea89
commit c7b17ad413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 503 additions and 150 deletions

View File

@ -257,6 +257,7 @@
"pngjs": "^6.0.0",
"postcss": "^8.4.14",
"postcss-loader": "^4.3.0",
"process": "^0.11.10",
"raw-loader": "^4.0.2",
"sass-loader": "^10.0.1",
"storybook-addon-pseudo-states": "1.15.1",
@ -266,8 +267,8 @@
"ts-json-schema-generator": "^1.2.0",
"ts-node": "^10.9.1",
"typescript": "~4.9.5",
"webpack": "^4.46.0",
"webpack-cli": "^4.5.0",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"whatwg-fetch": "^3.6.2"
},
"optionalDependencies": {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
/* global require, module, process, __dirname */
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin')
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin')
@ -40,7 +41,6 @@ function createEntry(entry) {
},
output: {
path: path.resolve(__dirname, 'frontend', 'dist'),
filename: '[name].js',
chunkFilename: '[name].[contenthash].js',
publicPath: process.env.JS_URL
? `${process.env.JS_URL}${process.env.JS_URL.endsWith('/') ? '' : '/'}static/`
@ -60,13 +60,14 @@ function createEntry(entry) {
types: path.resolve(__dirname, 'frontend', 'types'),
public: path.resolve(__dirname, 'frontend', 'public'),
cypress: path.resolve(__dirname, 'cypress'),
process: 'process/browser',
},
},
module: {
rules: [
{
test: /\.stories\.[jt]sx?$/,
loaders: [require.resolve('@storybook/source-loader')],
use: [require.resolve('@storybook/source-loader')],
},
{
test: /\.[jt]sx?$/,
@ -205,7 +206,12 @@ function createEntry(entry) {
new HtmlWebpackHarddiskPlugin(),
]
: entry === 'cypress'
? [new HtmlWebpackHarddiskPlugin()]
? [
new HtmlWebpackHarddiskPlugin(),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
]
: []
),
}