You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
3.3 KiB
JavaScript
128 lines
3.3 KiB
JavaScript
// Copyright (C) 2021 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const path = require('path');
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const DtsBundleWebpack = require('dts-bundle-webpack');
|
|
|
|
const styleLoaders = [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 2,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
options: {
|
|
plugins: [require('postcss-preset-env')],
|
|
},
|
|
},
|
|
'sass-loader',
|
|
];
|
|
|
|
const nodeConfig = {
|
|
target: 'node',
|
|
mode: 'production',
|
|
devtool: 'source-map',
|
|
entry: './src/typescript/canvas3d.ts',
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: 'cvat-canvas3d.node.js',
|
|
library: 'canvas3d',
|
|
libraryTarget: 'commonjs',
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts', '.js', '.json'],
|
|
},
|
|
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', { targets: 'node > 10' }], '@babel/typescript'],
|
|
sourceType: 'unambiguous',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
test: /\.(css|scss)$/,
|
|
exclude: /node_modules/,
|
|
use: styleLoaders,
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new DtsBundleWebpack({
|
|
name: 'cvat-canvas3d.node',
|
|
main: 'dist/declaration/src/typescript/canvas3d.d.ts',
|
|
out: '../cvat-canvas3d.node.d.ts',
|
|
}),
|
|
],
|
|
};
|
|
|
|
const webConfig = {
|
|
target: 'web',
|
|
mode: 'production',
|
|
devtool: 'source-map',
|
|
entry: {
|
|
'cvat-canvas3d': './src/typescript/canvas3d.ts',
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: '[name].[contenthash].js',
|
|
library: 'canvas3d',
|
|
libraryTarget: 'window',
|
|
},
|
|
devServer: {
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
compress: false,
|
|
inline: true,
|
|
port: 3000,
|
|
},
|
|
resolve: {
|
|
extensions: ['.ts', '.js', '.json'],
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
exclude: /node_modules/,
|
|
use: {
|
|
loader: 'babel-loader',
|
|
options: {
|
|
plugins: ['@babel/plugin-proposal-class-properties'],
|
|
presets: ['@babel/preset-env', '@babel/typescript'],
|
|
sourceType: 'unambiguous',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
test: /\.scss$/,
|
|
exclude: /node_modules/,
|
|
use: styleLoaders,
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
new DtsBundleWebpack({
|
|
name: 'cvat-canvas3d',
|
|
main: 'dist/declaration/src/typescript/canvas3d.d.ts',
|
|
out: '../cvat-canvas3d.d.ts',
|
|
}),
|
|
],
|
|
};
|
|
|
|
module.exports = [webConfig, nodeConfig];
|