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

Problems with SVG or HTML files #82

Open
chawax opened this issue Oct 18, 2018 · 1 comment
Open

Problems with SVG or HTML files #82

chawax opened this issue Oct 18, 2018 · 1 comment

Comments

@chawax
Copy link

chawax commented Oct 18, 2018

Hi,

I have a problem importing html or SVG assets. And I think the problem occurs with any files that are not JS, TS or JSON ones.

For example :

import htmlContent from '../Assets/test.html'
import svgContent  from '../Assets/test.svg'

The htmlContent and svgContent variables contains the value 1 and not the content of HTML or SVG file. I had not this problem using ES6, so I think it comes from Typescript but I can't find any solution.

I am using React Native 0.55.4. Tried with a 0.57.2 project and I have the same problem.

My rn-cli.config.js file :

module.exports = {
  getTransformModulePath() {
    return require.resolve("react-native-typescript-transformer");
  },
  getSourceExts() {
    return ["ts", "tsx"];
  }
};

Thanks for any help.

@chawax
Copy link
Author

chawax commented Oct 18, 2018

I also tried to add this in index.d.ts file :

declare module '*.svg' {
  const content: string
  export default content
}

declare module '*.html' {
  const content: string
  export default content
}

It solved the Can not find module error in VSCode, but the content is always 1.

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

No branches or pull requests

1 participant