I have did the following in order to integrate pug with a newly created reactjs application :
1. Create a fresh reactjs app using create-react-app
2. Then I followed the instruction from babel-plugin-transform-react-pug to install the plugin as mentioned in pugjs official site.
I used npm install --save-dev babel-plugin-transform-react-pug to install the above plugin.
Then I've created a .babelrc file in my root directory and add the following in .babelrc file
{
"plugins": [
"transform-react-pug",
"transform-react-jsx"
]
}
3. In my react app I've created an App component like the following :
import React from "react"
class App extends React.Component {
render() {
return pug`
div
h1 My Component
p This is my component using pug.
`;
}
}
export default App;
But whenever I run the app usng npm start, I get the error message
./src/App.js Line 5: 'pug' is not defined no-undef