EDIT
I am trying to find a way in gatsby that
public
which means they are accessible on a web server. Let's say I have a js file that I want to link to from web pages.
// src/pages/functions.js it's more complicated than this
someUsefulFunction = () => { ... }
// src/pages/index.jsx
render(){
return(
<div>
my web page.
<script src="./functions.js" />
</div>
)
}
src/pages/functions.js
is not a react component It is just a js files with some functions in it.
Since fuctions.js needs to be accessible on a web server, it is under src/pages
.
When I do gatsby develop
with the setups like above, it works fine, but when I do gatsby build
, it show errors like this
WebpackError: Invariant Violation: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
It looks very stupid to use script
tag when you can just import the file, but I am working on a project where there are conditions that I need to link my js files through script
tag.
Am I doing it wrong? or it's not possible to compile simple js files?
Do you have any other files under ./src/pages/ Other files can confuse gatsby( idk how but it can.)
check this here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.