I have a react application, which I built with create react app, when I run build it generates the static assets I need and then the index.html file. I am running this on a Ratpack server with gradle. I then use gradle to move these files to my Ratpack directory so I can run it with the Ratpack server. When I move the files I need to add /assets/ onto the url for the JS and CSS file.
For example at the moment it creates the path like this
<script type="text/javascript" src="/static/js/main.dab68f70.js">
where as I need
<script type="text/javascript" src="assets/static/js/main.dab68f70.js">
Is it possible to somehow automate this as each time I run my application the files in my ratpack assets are overwritten by the new files.
I have a react application, which I built with create react app, when I run build it generates the static assets I need and then the index.html file. I am running this on a Ratpack server with gradle. I then use gradle to move these files to my Ratpack directory so I can run it with the Ratpack server. When I move the files I need to add /assets/ onto the url for the JS and CSS file.
For example at the moment it creates the path like this
<script type="text/javascript" src="/static/js/main.dab68f70.js">
where as I need
<script type="text/javascript" src="assets/static/js/main.dab68f70.js">
Is it possible to somehow automate this as each time I run my application the files in my ratpack assets are overwritten by the new files.
Share Improve this question edited Feb 10, 2017 at 18:13 N P asked Feb 10, 2017 at 13:04 N PN P 2,6297 gold badges37 silver badges59 bronze badges4 Answers
Reset to default 4What about configuring Webpack output publicPath like this?
output: {
...
publicPath: "assets",
}
I am using this with Webpack 1.x
The docs can be found here: http://webpack.github.io/docs/configuration.html#output-publicpath
3 Years later......
I had this issue today. And found all the same answers I'm sure you did.
Here is how I fixed it, I went into the index.html file that loads those few files and changed the path manually.
Took about 3 minutes.
In the end I used npm eject, this then exposes all the config files for webpack. From here I edited my webpack config to get my desired paths for my assets.
You can add "homepage": ".",
in your package.json
file. It will make the build files with relative path. Bit weird though, but it worked for me.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745619623a4636440.html
评论列表(0条)