ToolJet/frontend/webpack.config.js
Gandharv a1fd1fc301
[Feature] Make plugins installable (#3069)
* feat: add user avatar

* update: @nest/platform-express from 8.0.0 to 8.4.4

* add avatar_id in login response

* add user avatar upload in frontend

* align cross divider with layout icons'

* generate nest model - extensions

* Add extensions module

* Add extension to datasouce

* add not implemented check

* create extension

* refactor

* cleanup

* fix tests

* reduce the avatar size on homepage

* poc: run js code from string

* resolve conflicts

* fix conflicts

* add globals

* add new route

* add icon, manifest file upload

* complete user flow

* add flow for data queries

* add dynamic manifest instead of local datasource types

* add version attr

* remove unused code

* add version

* rename extension(s) -> plugins(s)

* add test connection method

* feat: add marketplace listing page

* Add install plugin cmd + missing attrs {name, repo, desc} to plugin

* add missing icon

* - Add npm workspaces for marketplace monorepo
- Added cassandra datasource plugin
- Created upload to s3 script
- Created plugins.json entry file

* install plugin from s3 bucket

* cleanup

* update pkg locks

* fix icon render

* cleanup

* marketplace changes

* ui changes

* operations file load fix + revert vm2

* update module from string to 3.2.1

* load plugins.json from local file instead of remote

* install plugin from local file if not production environment

* add sqlite

* feat: add plivo api plugin

* exp: add heroku 22 stack

* update assets include path

* Revert "exp: add heroku 22 stack"

This reverts commit a8926b36e1.

* add integrations link

* Add casl ability for plugin

* load host from env else fallback to default

* update imports

* remove sqlite

* typo

* add marketplace flag to cli command

* move ts and ncc to devDep

* add hygen templates for marketplace

* cli tree-node path fix

* template indent fix

* TOOLJET_URL -> MARKETPLACE_TOOLJET_URL

* add tests

* refactor: move to plugins.helper for get-service helper utility

* fix; typo

* update package-lock.json

* review changes

* remove a href

* remove bg color + redirect issue due to href

* add test url

* fix crash on search

* remove extra slash

* feat: allow plugin to be installed from github repository

* remove unwanted args from cli command

* add repo attr while save

* feat: add feature toggle for marketplace feature

* fix: make default config as false

* chore: remove hyperlink

* fix: failing build

* chore: update s3 url to point to prod

* fix failing test

* fix test

* fix: test case

* update module from string pkg

* update env

* fix test

* fix test

* add readme file

* Update README.md

Co-authored-by: Akshay Sasidharan <[email protected]>
2022-10-27 16:59:43 +05:30

167 lines
4.1 KiB
JavaScript

var HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const environment = process.env.NODE_ENV === 'production' ? 'production' : 'development';
const API_URL = {
production: process.env.TOOLJET_SERVER_URL || (process.env.SERVE_CLIENT !== 'false' ? '__REPLACE_SUB_PATH__' : ''),
development: `http://localhost:${process.env.TOOLJET_SERVER_PORT || 3000}`,
};
const ASSET_PATH = process.env.ASSET_PATH || '';
function stripTrailingSlash(str) {
return str.replace(/[/]+$/, '');
}
module.exports = {
mode: environment,
optimization: {
minimize: environment === 'production',
usedExports: true,
runtimeChunk: 'single',
minimizer: [
new TerserPlugin({
minify: TerserPlugin.esbuildMinify,
terserOptions: {
...(environment === 'production' && { drop: ['debugger'] }),
},
parallel: environment === 'production',
}),
],
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
},
},
},
},
target: 'web',
resolve: {
extensions: ['.js', '.jsx', '.png', '.wasm', '.tar', '.data'],
alias: {
'@': path.resolve(__dirname, 'src/'),
'@ee': path.resolve(__dirname, 'ee/'),
},
},
devtool: environment === 'development' ? 'inline-source-map' : false,
module: {
rules: [
{
test: /\.ttf$/,
use: ['file-loader'],
},
{
test: /\.wasm$/,
use: ['file-loader'],
},
{
test: /\.tar$/,
use: ['file-loader'],
},
{
test: /\.data$/,
use: ['file-loader'],
},
{
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
limit: 10000,
},
},
],
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
],
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
},
],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
resolve: {
extensions: ['.js', '.jsx'],
},
use: {
loader: 'babel-loader',
options: {
plugins: [
['import', { libraryName: 'lodash', libraryDirectory: '', camel2DashComponentName: false }, 'lodash'],
],
},
},
},
{
test: /\.html$/,
loader: 'html-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.ejs',
favicon: './assets/images/logo.svg',
}),
new CompressionPlugin({
test: /\.js(\?.*)?$/i,
algorithm: 'gzip',
}),
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en)$/),
new webpack.DefinePlugin({
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
'process.env.SERVE_CLIENT': JSON.stringify(process.env.SERVE_CLIENT),
}),
],
devServer: {
historyApiFallback: { index: ASSET_PATH },
static: {
directory: path.resolve(__dirname, 'assets'),
publicPath: '/assets/',
},
},
output: {
publicPath: ASSET_PATH,
path: path.resolve(__dirname, 'build'),
},
externals: {
// global app config object
config: JSON.stringify({
apiUrl: `${stripTrailingSlash(API_URL[environment]) || ''}/api`,
SERVER_IP: process.env.SERVER_IP,
COMMENT_FEATURE_ENABLE: process.env.COMMENT_FEATURE_ENABLE ?? true,
ENABLE_MARKETPLACE_FEATURE: process.env.ENABLE_MARKETPLACE_FEATURE ?? false,
ENABLE_MULTIPLAYER_EDITING: true,
TOOLJET_MARKETPLACE_URL:
process.env.TOOLJET_MARKETPLACE_URL || 'https://tooljet-plugins-production.s3.us-east-2.amazonaws.com',
}),
},
};