| import process from 'node:process'; |
| import path from 'node:path'; |
| import isDocker from 'is-docker'; |
| import webpack from 'webpack'; |
| import { serverDirectory } from './src/server-directory.js'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export default function getPublicLibConfig(forceDist = false) { |
| function getCacheDirectory() { |
| if (forceDist || isDocker()) { |
| return path.resolve(process.cwd(), 'dist', '_webpack', webpack.version, 'cache'); |
| } |
|
|
| if (typeof globalThis.DATA_ROOT === 'string') { |
| return path.resolve(globalThis.DATA_ROOT, '_webpack', webpack.version, 'cache'); |
| } |
|
|
| throw new Error('DATA_ROOT variable is not set.'); |
| } |
|
|
| function getOutputDirectory() { |
| if (forceDist || isDocker()) { |
| return path.resolve(process.cwd(), 'dist', '_webpack', webpack.version, 'output'); |
| } |
|
|
| if (typeof globalThis.DATA_ROOT === 'string') { |
| return path.resolve(globalThis.DATA_ROOT, '_webpack', webpack.version, 'output'); |
| } |
|
|
| throw new Error('DATA_ROOT variable is not set.'); |
| } |
|
|
| const cacheDirectory = getCacheDirectory(); |
| const outputDirectory = getOutputDirectory(); |
|
|
| return { |
| mode: 'production', |
| entry: path.join(serverDirectory, 'public/lib.js'), |
| cache: { |
| type: 'filesystem', |
| cacheDirectory: cacheDirectory, |
| store: 'pack', |
| compression: 'gzip', |
| }, |
| devtool: false, |
| watch: false, |
| module: {}, |
| stats: { |
| preset: 'minimal', |
| assets: false, |
| modules: false, |
| colors: true, |
| timings: true, |
| }, |
| experiments: { |
| outputModule: true, |
| }, |
| performance: { |
| hints: false, |
| }, |
| output: { |
| path: outputDirectory, |
| filename: 'lib.js', |
| libraryTarget: 'module', |
| }, |
| }; |
| } |
|
|