UNPKG

ffbt

Version:

Build a Typescript app without pain

49 lines (48 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); const read_json_1 = require("../../../../core/read-json"); const layer = (projectConfig) => { const { paths } = projectConfig; const tsConfigPath = paths.projectTsConfig; const tsConfig = read_json_1.readJson(tsConfigPath); const plugins = []; if (projectConfig.env.enableTypeChecking) { plugins.push(new ForkTsCheckerWebpackPlugin({ typescript: { configFile: tsConfigPath, profile: projectConfig.env.verboseMode, } })); } return { devtool: projectConfig.env.sourceMapType, entry: { main: paths.projectEntrypoint, }, resolve: { extensions: [".ts", ".tsx", ".js", ".json"], }, module: { rules: [ { test: /\.tsx?$/, loader: "ts-loader", options: { configFile: tsConfigPath, compilerOptions: { jsx: tsConfig.compilerOptions.jsx || "react", }, experimentalWatchApi: true, // disable type checker - we will use it in fork plugin transpileOnly: true, logLevel: projectConfig.env.verboseMode ? "info" : "warn", logInfoToStdOut: projectConfig.env.verboseMode, }, }, ], }, plugins, }; }; module.exports = layer;