mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* make the server port configurable in the frontend project * add documentation for new env variable
115 lines
2.6 KiB
JavaScript
115 lines
2.6 KiB
JavaScript
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const webpack = require('webpack');
|
|
const path = require('path');
|
|
|
|
const environment = process.env.NODE_ENV === 'production' ? 'production' : 'development';
|
|
|
|
const API_URL = {
|
|
production: process.env.TOOLJET_SERVER_URL || '',
|
|
development: `http://localhost:${process.env.TOOLJET_SERVER_PORT || 3000}`,
|
|
};
|
|
|
|
const ASSET_PATH = process.env.ASSET_PATH || '/';
|
|
|
|
module.exports = {
|
|
mode: environment,
|
|
optimization: {
|
|
usedExports: true,
|
|
},
|
|
target: 'web',
|
|
resolve: {
|
|
extensions: ['.js', '.jsx', '.png'],
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src/'),
|
|
'@ee': path.resolve(__dirname, 'ee/'),
|
|
},
|
|
},
|
|
devtool: environment === 'development' ? 'inline-source-map' : 'source-map',
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ttf$/,
|
|
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'],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: './src/index.html',
|
|
}),
|
|
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en)$/),
|
|
new webpack.DefinePlugin({
|
|
'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
|
|
}),
|
|
],
|
|
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: `${API_URL[environment] || ''}/api`,
|
|
SERVER_IP: process.env.SERVER_IP,
|
|
COMMENT_FEATURE_ENABLE: true,
|
|
}),
|
|
},
|
|
};
|