Configure absolute path resolution in ts and webpack

This lets us write imports like "@src/stuff" instead of "../../stuff"
This commit is contained in:
Saul Reynolds-Haertle 2018-09-29 15:29:51 -07:00
parent dc064d322f
commit ac114562b6
3 changed files with 15 additions and 4 deletions

View file

@ -49,7 +49,7 @@
},
"jest": {
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
@ -58,7 +58,10 @@
"js",
"jsx",
"json"
]
],
"moduleNameMapper": {
"@src/(.*)": "<rootDir>/src/$1"
}
},
"author": "Colin Caine",
"repository": {

View file

@ -8,12 +8,16 @@
"target": "ES2017",
"lib": ["ES2017","dom", "dom.iterable"],
"typeRoots": ["node_modules/@types", "node_modules/web-ext-types/"],
"alwaysStrict": true
"alwaysStrict": true,
"baseUrl": "src/",
"paths": {
"@src/*": ["*"],
}
},
"include": [
"./src/**/*"
],
"exclude": [
"./src/**/*.test.ts"
"./src/**/*.test.ts"
]
}

View file

@ -1,3 +1,4 @@
const { TsConfigPathsPlugin } = require('awesome-typescript-loader');
const UglifyJSPlugin = require("uglifyjs-webpack-plugin")
const CopyWebPackPlugin = require("copy-webpack-plugin")
// const WebpackShellPlugin = require('webpack-shell-plugin')
@ -22,6 +23,9 @@ module.exports = {
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"],
plugins: [
new TsConfigPathsPlugin(),
],
},
module: {