Skip to content

Commit

Permalink
update webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Aug 10, 2024
1 parent f79ea56 commit e327ef0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/shinkai-tool-internet-search-perplexity/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BaseTool, RunResult } from '@shinkai_protocol/shinkai-tools-builder';
import { ToolDefinition } from 'libs/shinkai-tools-builder/src/tool-definition';

const TurndownService = require('turndown');
const { chromium } = require('playwright-extra');
// const fs = require('fs');
Expand Down
63 changes: 60 additions & 3 deletions apps/shinkai-tool-internet-search-perplexity/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import * as path from 'path';
import * as webpack from 'webpack';
import { composePlugins, withNx } from '@nx/webpack';
import { merge } from 'lodash';
import { withToolWebpackConfig } from '@shinkai_protocol/shinkai-tools-bundler';
import webpack from 'webpack';

module.exports = composePlugins(withNx(), (config, { options, context }) => {
return merge(
config,
withToolWebpackConfig({
entry: path.join(__dirname, 'src/index.ts'),
outputPath: path.join(__dirname, '../../dist/apps/shinkai-tool-internet-search-perplexity'),
outputPath: path.join(
__dirname,
'../../dist/apps/shinkai-tool-internet-search-perplexity',
),
tsConfigFile: path.join(__dirname, 'tsconfig.app.json'),
}),
{
Expand All @@ -18,13 +21,67 @@ module.exports = composePlugins(withNx(), (config, { options, context }) => {
os: require.resolve('os-browserify/browser'),
tty: require.resolve('tty-browserify'),
util: require.resolve('util/'),
process: require.resolve('process/browser'),
},
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
// Add IgnorePlugin to ignore dynamic requires
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/.*$/,
contextRegExp: /merge-deep\/node_modules\/clone-deep/,
}),
// Optionally, you can use ContextReplacementPlugin
new webpack.ContextReplacementPlugin(
/merge-deep\/node_modules\/clone-deep/,
(data: { dependencies: { critical?: boolean }[] }) => {
delete data.dependencies[0].critical;
return data;
},
),
// ContextReplacementPlugin for playwright-extra
new webpack.ContextReplacementPlugin(
/playwright-extra/,
(data: { dependencies: { critical?: boolean }[] }) => {
if (data.dependencies[0]) {
delete data.dependencies[0].critical;
}
return data;
},
),
// ContextReplacementPlugin for tsconfig-paths
new webpack.ContextReplacementPlugin(
/tsconfig-paths/,
(data: { dependencies: { critical?: boolean }[] }) => {
if (data.dependencies[0]) {
delete data.dependencies[0].critical;
}
return data;
},
),
// ContextReplacementPlugin for tsconfig-paths filesystem.js
new webpack.ContextReplacementPlugin(
/tsconfig-paths\/lib\/filesystem/,
(data: { dependencies: { critical?: boolean }[] }) => {
if (data.dependencies[0]) {
delete data.dependencies[0].critical;
}
return data;
},
),
// ContextReplacementPlugin for tsconfig-paths specific files
new webpack.ContextReplacementPlugin(
/tsconfig-paths\/lib\/match-path-async/,
(data: { dependencies: { critical?: boolean }[] }) => {
if (data.dependencies[0]) {
delete data.dependencies[0].critical;
}
return data;
},
),
],
}
},
);
});

0 comments on commit e327ef0

Please sign in to comment.