[x] I checked the documentation and found no answer
[x] I checked to make sure that this issue has not already been filed
[x] I'm reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)
Expected Behavior
Utilize an SVG file using the
1
tag in a React application.
Current Behavior
The application fails to compile with
1
nx serve
.
Failure Information (for bugs)
1 2
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
Steps to Reproduce
I personally discovered this when trying to use the Ionic React components in an Nx workspace, so will provide these steps to reproduce.
Generate a new Nx workspace with a default React application
1
yarn install /react
Wrap the contents of the default
1
app.tsx
JSX with
1
1
nx serve
If you can provide steps to reproduce from scratch, that would be enormously appreciated (i.e. where the first step is
1
npx create-nx-workspace repro-workspace
)
Context
Please provide any relevant information about your setup:
Nx 8.6.0
/react 4.10.0-rc.3
Failure Logs
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ERROR in /Users/devinshoemaker/code/ionic/test-nx-ionic/node_modules/ionicons/dist/ionicons/svg/md-quote.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
>
ERROR in /Users/devinshoemaker/code/ionic/test-nx-ionic/node_modules/ionicons/dist/ionicons/svg/ios-school.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
>
ERROR in /Users/devinshoemaker/code/ionic/test-nx-ionic/node_modules/ionicons/dist/ionicons/svg/md-arrow-round-down.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
>
Other
I have found one other person that reported a similar issue, though it's not Ionic specific. The solution proposed here involved overriding the default webpack config that Nx uses for it's React applications, however that config did not work for me, and I am not adept enough with webpack yet to get this working. I have been inspecting the
1
create-creact-app
1
webpack.config.js
(which is what Ionic uses in it's generated projects) and will continue to try and get an override working, but this does seem like something that should be available out of the box.
1
create-react-app
applications are quite popular, so I imagine many people will eventually run into this issue when using React with Nx.