From f84af9a44b39d11d80c17920f67ae717d0267832 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Fri, 29 Dec 2017 01:11:59 +0000 Subject: [PATCH] Move tsconfig files to root, and made webpack config build --- package.json | 7 ++++--- src/tests/utility.ts | 1 + src/test-tsconfig.json => test-tsconfig.json | 9 ++++++--- src/tsconfig.json => tsconfig.json | 9 +++++---- src/tslint.json => tslint.json | 0 webpack.config.js | 20 +++++++------------- 6 files changed, 23 insertions(+), 23 deletions(-) rename src/test-tsconfig.json => test-tsconfig.json (69%) rename src/tsconfig.json => tsconfig.json (75%) rename src/tslint.json => tslint.json (100%) diff --git a/package.json b/package.json index 8b7f5d66ae..10fa6bba60 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,12 @@ "description": "Generate .docx documents with JavaScript (formerly Office-Clippy)", "main": "build/index.js", "scripts": { - "pretest": "rimraf ./build-tests && tsc -p src/test-tsconfig.json", + "pretest": "rimraf ./build-tests && tsc -p ./test-tsconfig.json", "test": "mocha ./build-tests --recursive", "prepublishOnly": "npm run build", - "lint": "tslint --project ./src", - "build": "rimraf ./build && tsc -p src", + "lint": "tslint --project .", + "build": "npm run tsc", + "tsc": "rimraf ./build && tsc -p .", "webpack": "rimraf ./build && webpack", "demo": "npm run build && node ./demo", "typedoc": "typedoc --out docs/ src/ --module commonjs --target ES6 --disableOutputCheck" diff --git a/src/tests/utility.ts b/src/tests/utility.ts index f89701b726..c43d0f6cc3 100644 --- a/src/tests/utility.ts +++ b/src/tests/utility.ts @@ -1,4 +1,5 @@ export class Utility { + // tslint:disable-next-line:no-any public static jsonify(obj: object): any { const stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); diff --git a/src/test-tsconfig.json b/test-tsconfig.json similarity index 69% rename from src/test-tsconfig.json rename to test-tsconfig.json index b8c28cb188..606934f43c 100644 --- a/src/test-tsconfig.json +++ b/test-tsconfig.json @@ -5,14 +5,17 @@ "sourceMap": true, "removeComments": true, "preserveConstEnums": true, - "outDir": "../build-tests", - "sourceRoot": "./", - "rootDir": "./", + "outDir": "./build-tests", + "sourceRoot": "./src", + "rootDir": "./src", "module": "commonjs", "noUnusedLocals": true }, "include": [ "**/*.spec.ts", "**/*.d.ts" + ], + "exclude": [ + "node_modules" ] } diff --git a/src/tsconfig.json b/tsconfig.json similarity index 75% rename from src/tsconfig.json rename to tsconfig.json index 6d075e7f8a..6427330d2d 100644 --- a/src/tsconfig.json +++ b/tsconfig.json @@ -5,13 +5,13 @@ "sourceMap": true, "removeComments": true, "preserveConstEnums": true, - "outDir": "../build", - "sourceRoot": "./", - "rootDir": "./", + "outDir": "./build", + "sourceRoot": "./src", + "rootDir": "./src", "module": "commonjs", "declaration": true, "noUnusedLocals": true, - "baseUrl": "./", + "baseUrl": "./src", "paths" : { "/*": [ "./*" @@ -19,6 +19,7 @@ } }, "exclude": [ + "node_modules", "tests", "**/*.spec.ts", "**/_*" diff --git a/src/tslint.json b/tslint.json similarity index 100% rename from src/tslint.json rename to tslint.json diff --git a/webpack.config.js b/webpack.config.js index 847516f798..57d4623375 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,31 +1,25 @@ const path = require('path'); -const { TsConfigPathsPlugin } = require('awesome-typescript-loader'); module.exports = { entry: './src/index.ts', output: { path: path.resolve('build'), - filename: 'bundle.js' + filename: 'index.js' }, resolve: { - extensions: ['.ts', '.tsx', '.js'], - plugins: [ - new TsConfigPathsPlugin(/* { configFileName, compiler } */) - ] + extensions: ['.tsx', '.ts', '.js'] }, - // Source maps support ('inline-source-map' also works) - devtool: 'source-map', - module: { rules: [ { - test: /\.ts|\.tsx$/, - loader: 'awesome-typescript-loader', - exclude: [/^(?!.*\.spec\.ts$).*\.ts$/] + test: /\.ts$/, + loaders: ["awesome-typescript-loader"], } - ] + ], }, + + target: 'node' };