diff --git a/projectFilesManager.js b/projectFilesManager.js index 4fe8750e..09996cc8 100644 --- a/projectFilesManager.js +++ b/projectFilesManager.js @@ -57,21 +57,41 @@ function copyTemplate(templateName, destinationPath) { } function getProjectTemplates(projectDir) { - const templates = {} - const WEBPACK_CONFIG_NAME = "webpack.config.js"; + const TSCONFIG_ESM_NAME = "tsconfig.esm.json"; + + let templates; if (isAngular({projectDir})) { - templates["webpack.angular.js"] = WEBPACK_CONFIG_NAME; - templates["tsconfig.esm.json"] = "tsconfig.esm.json"; + templates = getAngularTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME); } else if (isTypeScript({projectDir})) { - templates["webpack.typescript.js"] = WEBPACK_CONFIG_NAME; + templates = getTypeScriptTemplates(WEBPACK_CONFIG_NAME, TSCONFIG_ESM_NAME); } else { - templates["webpack.javascript.js"] = WEBPACK_CONFIG_NAME; + templates = getJavaScriptTemplates(WEBPACK_CONFIG_NAME); } return getFullTemplatesPath(projectDir, templates); } +function getAngularTemplates(webpackConfigName, tsconfigName) { + return { + "webpack.angular.js": webpackConfigName, + [tsconfigName]: tsconfigName, + }; +} + +function getTypeScriptTemplates(webpackConfigName, tsconfigName) { + return { + "webpack.typescript.js": webpackConfigName, + [tsconfigName]: tsconfigName, + }; +} + +function getJavaScriptTemplates(webpackConfigName) { + return { + "webpack.javascript.js": webpackConfigName, + }; +} + function getFullTemplatesPath(projectDir, templates) { let updatedTemplates = {}; diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index b42b79de..6f223b11 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -166,7 +166,13 @@ module.exports = env => { ] }, - { test: /\.ts$/, use: "awesome-typescript-loader" } + { + test: /\.ts$/, + use: { + loader: "awesome-typescript-loader", + options: { configFileName: "tsconfig.esm.json" }, + } + }, ] }, plugins: [