mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 09:14:46 +01:00
f71e011a86
* add hotkey base * add platform check * Rename CommandBox to CommandPalette * Add styled-components * Restructure CommandPalette and add Esc handling * Update utils.js * add search box * Add logic types * Implement base logic * Fix scroll prevention * Update logic and add goto command base with Fuse fuzzy serach * ux hotkey * Implement command (de)registration * minor fix * base UI * error message & hints * command groups UI * Add commands search * Make commands work * Prepare palette for fuzzy search and add basic labeling * ui adjustments * ui * Improve colors * switch to global command * Optimize resolution * global go to commands * abstract item selection logic to command palette * Update casing and types * Add conditional useCommands * Improve results * keyboard nav * keyboard nav fix * removed double fuse (synonyms broken) * Update style * Fix highlighting * Remove extra style * conditional go to commands * add mouse hover handling and rename functions * remove mac check * add more commands * added insights stub pages * Add command components * refactor logic * Update styling * Remove extraneous `input` * load custom dashboards to command palette * Add input styling * Add write icon * Refactor results * minor adjustments * add person search * remove papercups fully * fix input indexing * fix result executing empty * Add command grouping and improve navigation * add urls * make logic explicit * fix error with hadnler * Remove redundant border-top * add trend functions * personal api key stub * Add command palette toggle button * Fix things * fix personal api keys * copy api key to clipboard * Add toggle text * Improve palette UX and perform refactoring * Improve UX and add palette usage reporting * tests refactor * filter person list * refactor api person tests * add squeak * deprecate by_distinct_id & by_email person endpoints * Optimize squeak * fix typegen error * use new filters in frontend * Optimize squeak * key identifier refactor * fix mypy * removed unused code * Make custom command UI more coherent * Add calculator to palette * Use equal sign * Make palette button nicer * Add lodash back officially and show palette suggestions lodash is still used in a few places, but it was not in package.json. The reason this was working was that lodash is a dependency of some other depedencies, but this was fragile. It's still not ideal to use this, but at least this is now not a hack the way it was. * Remove isHint * Optimize graph time range command * Move command results grouping to Kea logic * Fix result focus autoshift * Improve palette result focusing * Adjust for window.posthog being optional * add test for third-party person filters * Remove styled-components in favor of .scss files * Remove redundant container class * Use insect (sic!) squeak instead of pig squeak * Show only unique palette results * Fix palette overlay * Add powerful command building protocol CommandFlow * Fix minor issues * Always show scope when flow active * Use custom label icon * Add feedback sharing command * block command input from being captured in screen recording at least until we can figure out how to capture this info in a privacy-preserving way * Hide palette button on narrow screens * Improve responsiveness * Fix palette feedback sending * Fix Esc handling * Add Message Sent info * Fix Message Sent info * Fix dashboard creation and null name handling * Rename Cy tests to JS convention * Add basic Cypress test * Address feedback Co-authored-by: Eric <eeoneric@gmail.com> Co-authored-by: Paolo D'Amico <paolodamico@users.noreply.github.com>
238 lines
9.7 KiB
JavaScript
238 lines
9.7 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
/* global require, module, process, __dirname */
|
|
const path = require('path')
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin')
|
|
|
|
const webpackDevServerHost = process.env.WEBPACK_HOT_RELOAD_HOST || '127.0.0.1'
|
|
|
|
// main = app
|
|
// toolbar = new toolbar
|
|
// editor = old toolbar
|
|
// shared_dashboard = publicly available dashboard
|
|
module.exports = () => [
|
|
createEntry('main'),
|
|
createEntry('toolbar'),
|
|
createEntry('editor'),
|
|
createEntry('shared_dashboard'),
|
|
]
|
|
|
|
function createEntry(entry) {
|
|
return {
|
|
name: entry,
|
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
|
devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'inline-source-map',
|
|
entry: {
|
|
[entry]:
|
|
entry === 'main'
|
|
? './frontend/src/index.tsx'
|
|
: entry === 'toolbar'
|
|
? './frontend/src/toolbar/index.tsx'
|
|
: entry === 'editor'
|
|
? './frontend/src/editor/index.js'
|
|
: entry === 'shared_dashboard'
|
|
? './frontend/src/scenes/dashboard/SharedDashboard.js'
|
|
: null,
|
|
},
|
|
watchOptions: {
|
|
ignored: /node_modules/,
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'frontend', 'dist'),
|
|
filename: '[name].js',
|
|
chunkFilename: '[name].[contenthash].js',
|
|
publicPath:
|
|
process.env.NODE_ENV === 'production'
|
|
? '/static/'
|
|
: process.env.JS_URL
|
|
? `${process.env.JS_URL}${process.env.JS_URL.endsWith('/') ? '' : '/'}static/`
|
|
: process.env.IS_PORTER
|
|
? `https://${process.env.PORTER_WEBPACK_HOST}/static/`
|
|
: `http${process.env.LOCAL_HTTPS ? 's' : ''}://${webpackDevServerHost}:8234/static/`,
|
|
},
|
|
resolve: {
|
|
extensions: ['.js', '.ts', '.tsx'],
|
|
alias: {
|
|
'~': path.resolve(__dirname, 'frontend', 'src'),
|
|
lib: path.resolve(__dirname, 'frontend', 'src', 'lib'),
|
|
scenes: path.resolve(__dirname, 'frontend', 'src', 'scenes'),
|
|
types: path.resolve(__dirname, 'frontend', 'types'),
|
|
...(process.env.NODE_ENV !== 'production'
|
|
? {
|
|
'react-dom': '@hot-loader/react-dom',
|
|
}
|
|
: {}),
|
|
},
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.[jt]sx?$/,
|
|
exclude: /(node_modules)/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
},
|
|
},
|
|
{
|
|
// Apply rule for .sass, .scss or .css files
|
|
test: /\.(sa|sc|c)ss$/,
|
|
|
|
// Set loaders to transform files.
|
|
// Loaders are applying from right to left(!)
|
|
// The first loader will be applied after others
|
|
use: [
|
|
entry === 'main' || entry === 'shared_dashboard'
|
|
? {
|
|
// After all CSS loaders we use plugin to do his work.
|
|
// It gets all transformed CSS and extracts it into separate
|
|
// single bundled file
|
|
loader: MiniCssExtractPlugin.loader,
|
|
}
|
|
: entry === 'toolbar'
|
|
? {
|
|
loader: 'style-loader',
|
|
options: {
|
|
insert: function insertAtTop(element) {
|
|
// tunnel behind the shadow root
|
|
if (window.__PHGTLB_ADD_STYLES__) {
|
|
window.__PHGTLB_ADD_STYLES__(element)
|
|
} else {
|
|
if (!window.__PHGTLB_STYLES__) {
|
|
window.__PHGTLB_STYLES__ = []
|
|
}
|
|
window.__PHGTLB_STYLES__.push(element)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
: null,
|
|
{
|
|
// This loader resolves url() and @imports inside CSS
|
|
loader: 'css-loader',
|
|
},
|
|
{
|
|
// Then we apply postCSS fixes like autoprefixer and minifying
|
|
loader: 'postcss-loader',
|
|
},
|
|
{
|
|
// First we transform SASS to standard CSS
|
|
loader: 'sass-loader',
|
|
options: {
|
|
implementation: require('sass'),
|
|
},
|
|
},
|
|
].filter((a) => a),
|
|
},
|
|
{
|
|
// Now we apply rule for images
|
|
test: /\.(png|jpe?g|gif|svg)$/,
|
|
use: [
|
|
{
|
|
// Using file-loader for these files
|
|
loader: 'file-loader',
|
|
|
|
// In options we can set different things like format
|
|
// and directory to save
|
|
options: {
|
|
name: '[name].[contenthash].[ext]',
|
|
outputPath: 'images',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// Apply rule for fonts files
|
|
test: /\.(woff|woff2|ttf|otf|eot)$/,
|
|
use: [
|
|
{
|
|
// Using file-loader too
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[contenthash].[ext]',
|
|
outputPath: 'fonts',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// Apply rule for sound files
|
|
test: /\.(mp3)$/,
|
|
use: [
|
|
{
|
|
// Using file-loader too
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[contenthash].[ext]',
|
|
outputPath: 'sounds',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
devServer: {
|
|
contentBase: path.join(__dirname, 'frontend', 'dist'),
|
|
hot: true,
|
|
host: webpackDevServerHost,
|
|
port: 8234,
|
|
stats: 'minimal',
|
|
disableHostCheck: !!process.env.LOCAL_HTTPS,
|
|
public: process.env.JS_URL
|
|
? new URL(process.env.JS_URL).host
|
|
: process.env.IS_PORTER
|
|
? `${process.env.PORTER_WEBPACK_HOST}`
|
|
: `${webpackDevServerHost}:8234`,
|
|
allowedHosts: process.env.IS_PORTER
|
|
? [`${process.env.PORTER_WEBPACK_HOST}`, `${process.env.PORTER_SERVER_HOST}`]
|
|
: [],
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Headers': '*',
|
|
},
|
|
},
|
|
plugins: [
|
|
// common plugins for all entrypoints
|
|
].concat(
|
|
entry === 'main'
|
|
? [
|
|
// other bundles include the css in js via style-loader
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css',
|
|
ignoreOrder: true,
|
|
}),
|
|
// we need these only once per build
|
|
new HtmlWebpackPlugin({
|
|
alwaysWriteToDisk: true,
|
|
title: 'PostHog',
|
|
template: path.join(__dirname, 'frontend', 'src', 'index.html'),
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
alwaysWriteToDisk: true,
|
|
title: 'PostHog',
|
|
filename: 'layout.html',
|
|
inject: false,
|
|
template: path.join(__dirname, 'frontend', 'src', 'layout.ejs'),
|
|
}),
|
|
new HtmlWebpackHarddiskPlugin(),
|
|
]
|
|
: entry === 'shared_dashboard'
|
|
? [
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css',
|
|
ignoreOrder: true,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
alwaysWriteToDisk: true,
|
|
title: 'PostHog',
|
|
filename: 'shared_dashboard.html',
|
|
template: path.join(__dirname, 'frontend', 'src', 'shared_dashboard.ejs'),
|
|
}),
|
|
new HtmlWebpackHarddiskPlugin(),
|
|
]
|
|
: []
|
|
),
|
|
}
|
|
}
|