This repository was archived by the owner on Dec 1, 2019. It is now read-only.
This repository was archived by the owner on Dec 1, 2019. It is now read-only.
Advance Path Resolution Issue #346
Open
Description
webpack.config.file just the relevant parts
{
resolve: {
modules: [
'devtools',
'src',
'node_modules'
],
extensions: ['.ts', '.js', '.scss', '.html'],
alias: {
selectbox: path.resolve('src/webcomponents/selectbox/')
}
},
resolveLoader: {
modules: ['node_modules']
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('app'),
new webpack.HotModuleReplacementPlugin(),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve('src')
)
],
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
query: {
configFileName: './devtools/tsconfig.json'
}
},
{
loader: 'angular2-template-loader'
}
],
exclude: [/\.(e2e)\.ts$/]
}
]
}
}
tsconfig.file
{
"compilerOptions": {
"baseUrl": "../",
"paths": {
"*": [
"src/modules/*",
"src/webcomponents/*"
]
},
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [
"../node_modules/@types"
]
},
"exclude": [
"node_modules",
"../node_modules",
"**/*.spec.ts"
],
"awesomeTypescriptLoaderOptions": {
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false
}
project structure:
devtools
- tsconfig.json
- webpack.config.js
src
-
modules
-- app
--- app.ts -
webcomponents
-- selectbox
--- selectbox.ts
My aim is for this to work:
import { SelectboxComponent } from 'selectbox';
Right now, if i use alias in webpack.config it works, but i'm afraid it will lead to a very big file rather soon.
I've tried using const TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin
To my understanding it should take the paths from tsconfig.js and load them dynamically.
This does not work and any examples that i found related to this issue either have not worked or have been incomplete.
Am i doing something wrong or what?