UNPKG

@typed/test

Version:
41 lines 1.4 kB
import { existsSync } from 'fs'; import { basename, dirname } from 'path'; import { sync } from 'resolve'; import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'; import { findConfigFile } from 'typescript'; export const defaultWebpackConfig = (cwd, input, output) => { const configFile = findConfigFile(cwd, (fileName) => existsSync(fileName)); const tsLoader = sync('ts-loader', { basedir: __dirname }); if (!configFile) { throw new Error('Unable to find TypeScript configuration'); } return { mode: 'development', entry: input, devtool: 'inline-source-map', output: { path: dirname(output), filename: basename(output), library: 'TypedTest', libraryTarget: 'umd', }, module: { rules: [ { test: /\.tsx?$/, loader: tsLoader, options: { transpileOnly: true, configFile, }, }, ], }, resolve: { mainFields: ['module', 'jsnext:main', 'browser', 'main'], extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'], plugins: [new TsconfigPathsPlugin({ configFile })], }, }; }; //# sourceMappingURL=defaultWebpackConfig.js.map