// Copyright (C) 2020-2022 Intel Corporation // // SPDX-License-Identifier: MIT /* global __dirname:true */ const path = require('path'); const nodeConfig = { target: 'node', mode: 'development', devtool: 'source-map', entry: './src/api.ts', output: { path: path.resolve(__dirname, 'dist'), filename: 'cvat-core.node.js', libraryTarget: 'commonjs', }, resolve: { extensions: ['.ts', '.js'], }, module: { rules: [ { test: /.ts?$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { plugins: [ '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining', ], presets: ['@babel/preset-env', '@babel/typescript'], sourceType: 'unambiguous', }, }, }, ], }, stats: { warnings: false, }, }; const webConfig = { target: 'web', mode: 'production', devtool: 'source-map', entry: { 'cvat-core': './src/api.ts', }, output: { path: path.resolve(__dirname, 'dist'), filename: '[name].[contenthash].min.js', library: 'cvat-core.js', libraryTarget: 'window', }, resolve: { extensions: ['.ts', '.js'], }, module: { rules: [ { test: /.ts?$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { plugins: [ '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining', ], presets: ['@babel/preset-env', '@babel/typescript'], sourceType: 'unambiguous', }, }, }, { test: /3rdparty\/.*\.worker\.js$/, use: { loader: 'worker-loader', options: { publicPath: '/static/engine/js/3rdparty/', filename: '[name].[contenthash].js', esModule: false, }, }, }, { test: /\.worker\.js$/, exclude: /3rdparty/, use: { loader: 'worker-loader', options: { publicPath: '/static/engine/js/', filename: '[name].[contenthash].js', esModule: false, }, }, }, ], }, }; module.exports = [nodeConfig, webConfig];