With out some sort of a web pack plugin you cannot reference S3 files with an import statement. import is for local files only.
I recently solved a similar situation where I wanted to use s3 to host a configuration file.
I solved it with a useEffect hook and fetch to load the file from a url. For local development I use serve to host a local version and the exact url being a .env config value (and using dot-env to handle different build environments).
(note, I use almost exclusively functional react components. you could translate this to a class component and use componentDidMount)
const [data, setData] = useState([]);
useEffect(()=>{
fetch(process.env.REACT_APP_CONFIG_URL)
.then(response => response.json())
.then((jsonData) => {
// jsonData is parsed json object received from url
setData(jsonData)
})
.catch((error) => {
// handle your errors here
console.error(error)
})
},[]) //empty array to get `componentDidMount` only and not have the `useEffect` fire on `componentDidUpdate`
This gets the data into the react state and using cache headers limits how often a user grabs the config file.
As for the webpack plugin, this exists but I have never used it https://github.com/egoist/import-http