Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular: typescript pathmapping does not work #3258

Closed
morninng opened this issue Mar 22, 2018 · 3 comments
Closed

Angular: typescript pathmapping does not work #3258

morninng opened this issue Mar 22, 2018 · 3 comments

Comments

@morninng
Copy link

Issue details

I am using path mapping to call project from projects
<< tsconfig.json >>

    "baseUrl": ".",
    "paths": {
      "@lib-path/*": [
        "lib/*"

<< call from src >>

import { TestServiceService } from '@lib-path/test-lib/';
export class XXX{
constructor( private testServiceService: TestServiceService){} 
}

With this code, the angular itself works normally.
However storybook does not work with the following error

ERROR in /test/storybookPathIssue/src/app/app.component.ts
[tsl] ERROR in /storybookPathIssue/src/app/app.component.ts(3,36)
      TS2307: Cannot find module '@lib-path/test-lib/'.

Steps to reproduce

sample code
https://github.com/morninng/storybook-libpath-scsspath
minimum code is here.

ng serve
-> it works
npm run storybook
-> error TS2307: Cannot find module '@lib-path/test-lib' has happened

Please specify which version of Storybook and optionally any affected addons that you're running

"@storybook/angular": "^3.4.0-rc.2",
"@storybook/addon-notes": "^3.4.0-rc.2",
"@storybook/addon-actions": "^3.4.0-rc.2",
"@storybook/addon-links": "^3.4.0-rc.2",
"@storybook/addons": "^3.4.0-rc.2"

Affected platforms

Ubuntu 16.04

Comment

I have tried to use custom webpack. but none of them works with additional another issues.
it sometimes break the scss import by "@import 'variables';"

@igor-dv
Copy link
Member

igor-dv commented Mar 22, 2018

Duplicate to #2718

@igor-dv igor-dv closed this as completed Mar 22, 2018
@morninng
Copy link
Author

morninng commented Mar 22, 2018

I have set following code in webpack.config.js

const path = require('path');
const genDefaultConfig = require('@storybook/angular/dist/server/config/defaults/webpack.config.js');
module.exports = (baseConfig, env) => {
  const config = genDefaultConfig(baseConfig, env);
  const lib_path = path.join( __dirname ,  "../src/lib" );
  config.resolve.alias['@lib-path'] = lib_path;
  return config;
};

this setting has solved the issue.

@Humberd
Copy link

Humberd commented Jul 8, 2019

The config that worked for me was:

const path = require('path');

module.exports = {
  resolve: {
    alias: {
      '@ng-boost': path.join(__dirname, "../dist")
    }
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants