madecomfy / gatsby-plugin-asset-path Goto Github PK
View Code? Open in Web Editor NEWMove all of your JS and CSS build files, as well as the static folder into a subdirectory of your choice
Home Page: https://madecomfy.com.au
License: MIT License
Move all of your JS and CSS build files, as well as the static folder into a subdirectory of your choice
Home Page: https://madecomfy.com.au
License: MIT License
You're assuming this file exists.
https://github.com/madecomfy/gatsby-plugin-asset-path/blob/master/src/gatsby-node.js#L44
I've managed to integrate this but the browser location changes after the page finishes loading.
The page is visible, but if I hit reload it attempts to reload the nested page and 404s.
e.g. with pathPrefix
set to custom_asset_path
, my page /page
will load fine with all styles, but once the JS kicks in the browser's displayed url will be /custom_asset_path/page
. Hence, reloading fails.
It seems like the plugin is meant to disable the standard behaviour of pathPrefix
but it's not? Any ideas what I could be doing wrong?
I might have missed a step somewhere, but it seems that this works:
assetPrefix: `/assets`,
But this does not
assetPrefix: `https://foobar.netlify.com/assets`,
It seems trivial to detect //
and work out the desired folder structure that way
Edit: I've submitted a pull request to fix the issue
I cannot get this plugin to work together with gatsby-plugin-manifest
. The <link>
element created by that plugin assumes that manifest.webmanifest
is located at the project root, but this plugin moves the manifest to whatever I set the assetPrefix
to. I find no option to give gatsby-plugin-manifest
a path to where the file is situated, nor an option to tell this plugin to exclude the manifest. How have you other folks solved this? I guess there has to be a solution out there since I see that you explicitly target the manifest file in gatsby-node.js
.
Hi, I'm trying to use this plugin but no matter what I configure in pathPrefix
I get this error:
Error: Source and destination must not be the same.
I even tried copying the exact same config on the readme here but it didn't work.
Full error log:
error Plugin gatsby-plugin-asset-path returned an error
Error: Source and destination must not be the same.
- copy.js:237 checkStats
[aurum]/[gatsby-plugin-asset-path]/[fs-extra]/lib/copy/copy.js:237:17
- copy.js:227 fs.stat
[aurum]/[gatsby-plugin-asset-path]/[fs-extra]/lib/copy/copy.js:227:14
- polyfills.js:285
[aurum]/[graceful-fs]/polyfills.js:285:20
Versions:
gatsby": "^2.0.106
gatsby-plugin-asset-path": "^0.2.1
I'm getting this error while building in docker with image mhart/alpine-node:12.18.0
, building in local works fine with node v12.18.3
Error in "/usr/src/app/node_modules/gatsby-plugin-asset-path/gatsby-node.js":
Cannot find module 'babel-runtime/regenerator'
Require stack:
- /usr/src/app/node_modules/gatsby-plugin-asset-path/gatsby-node.js
- /usr/src/app/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js
- /usr/src/app/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
- /usr/src/app/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
- /usr/src/app/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
- /usr/src/app/node_modules/gatsby/dist/services/initialize.js
- /usr/src/app/node_modules/gatsby/dist/services/index.js
- /usr/src/app/node_modules/gatsby/dist/bootstrap/index.js
- /usr/src/app/node_modules/gatsby/dist/commands/build.js
- /usr/src/app/node_modules/gatsby-cli/lib/create-cli.js
- /usr/src/app/node_modules/gatsby-cli/lib/index.js
- /usr/src/app/node_modules/gatsby/dist/bin/gatsby.js
- /usr/src/app/node_modules/gatsby/cli.js
Looking in local node_modules
, the file gatsby-node.js
is importing the package babel-runtime/regenerator
which throws the error since the package doesnt exist.
Tried installing babel-runtime/regenerator
but got permissions error maybe due to it being private package or something.
Here's my package.json file.
{
"name": "shop",
"version": "0.1.0",
"scripts": {
"build": "gatsby build --prefix-paths",
"develop": "gatsby develop",
"serve": "gatsby serve --prefix-paths",
"lint:graphql": "eslint src/graphql/**/*.js"
},
"dependencies": {
"@apollo/react-hooks": "^3.1.5",
"@emotion/core": "^10.0.28",
"@emotion/react": "^11.1.4",
"@emotion/styled": "^10.0.27",
"@react-keycloak/web": "^2.1.1",
"@stripe/react-stripe-js": "^1.1.2",
"@stripe/stripe-js": "^1.11.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-context": "^1.0.20",
"apollo-link-http": "^1.5.17",
"apollo-link-ws": "^1.0.20",
"apollo-utilities": "^1.3.4",
"axios": "^0.21.1",
"core-js": "2.6.5",
"gatsby": "^2.30.1",
"gatsby-plugin-emotion": "^4.3.3",
"gatsby-plugin-portal": "^1.0.7",
"gatsby-plugin-postcss": "^2.3.3",
"gatsby-plugin-react-helmet": "^3.8.0",
"graphql": "^15.4.0",
"graphql-tag": "^2.11.0",
"isomorphic-fetch": "^2.2.1",
"jwt-decode": "^3.1.2",
"keycloak-js": "^10.0.2",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"postcss-import": "^12.0.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-google-places-autocomplete": "^2.1.0",
"react-helmet": "^6.1.0",
"react-html-parser": "^2.0.2",
"react-toast-notifications": "^2.4.0",
"rrule": "^2.6.6",
"subscriptions-transport-ws": "^0.9.18",
"ws": "^7.4.2"
},
"devDependencies": {
"autoprefixer": "^10.2.0",
"babel-preset-gatsby": "^0.10.0",
"eslint-plugin-graphql": "^4.0.0",
"gatsby-plugin-asset-path": "^3.0.2",
"postcss": "^8.2.3",
"postcss-preset-env": "^6.7.0",
"tailwindcss": "^2.0.2",
"twin.macro": "^2.0.8"
},
"repository": {
"type": "git",
"url": "https://github.com/dailykit/subscription-shop"
},
"bugs": {
"url": "https://github.com/dailykit/subscription-shop/issues"
}
}
After using the plugin, Gatsby cache stops working and every time page is reloaded, js and other files are refetched.
Expected: should load js and other files from disk/memory cache.
Plugin version: v3.0.4
Config:
assetPrefix: `/assets/${Date.now().toString()}`,
plugins: [
{
resolve: 'gatsby-plugin-asset-path',
options: {
paths: ['static', 'page-data'],
},
},
...
]
Hi!
I know there's been a lot back and forth about the move/copy strategy in this package. But we have some sites that has a lot of images. These sites more or less doubles in size when copying the assets instead of moving them, which gives us different problems.
Would you accept a pull request adding the option to copy instead of moving, and that we default to copying?
Error: EnsureResources was not able to find resources for path: "/"
This typically means that an issue occurred building components for that path.
Run `gatsby clean` to remove any cached elements
I've run gatsby clean a few times and it doesn't make a difference. Using standard options and have my assetPrefix
set to "gatsby".
Hey I'm just trying to get this working and I notice
https://github.com/madecomfy/gatsby-plugin-asset-path/blob/master/src/gatsby-node.js#L26
It seems to be still referencing pathPrefix
instead of assetPrefix
?
Is that right or am I completely missing something?
icons will be published in whatever assetPrefix
specifies, but gatsby-plugin-manifest needs to serve them from /icons
recommending reverting back to the copy method for these assets.
Sub directories in the static
folder are not moved to the asset directory.
This content in the static folder:
// static
- example.txt
- bundles
| - bundle1.js
| - bundle2.js
Gives this build:
// public
- assets
| - example.txt
- bundles
| - bundle1.js
| - bundle2.js
The problem here is that the bundles
directory is not moved to the assets
directory.
I think it is reasonable to assume that you want to do a recursive move, not just a shallow one.
I'll start working with a PR for this.
The new version of Gatsby changed the Browser and SSR API's.
Hello there, it seems that the plugin misses some assets files and folders. I'm thinking about:
assets
fonts
icons
*.json
*.map
Would you consider a PR to fix it?
I'm getting this error whenever I try to run gatsby build --prefix-paths
with the gatsby-plugin-asset-path config:
ERROR #11321 PLUGIN
"gatsby-plugin-asset-path" threw an error while running the onPostBuild lifecycle:
ENOENT: no such file or directory, stat 'public/sitemap.xml'
It works smoothly if I place a dummy sitemap.xml file in the public folder
My gatsby info is this:
System:
OS: macOS 10.15.3
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.5.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 79.0.3945.130
Firefox: 72.0.2
Safari: 13.0.5
npmPackages:
gatsby: ^2.19.7 => 2.19.21
gatsby-image: ^2.2.39 => 2.2.41
gatsby-plugin-asset-path: ^1.1.0 => 1.1.0
gatsby-plugin-manifest: ^2.2.39 => 2.2.42
gatsby-plugin-offline: ^3.0.32 => 3.0.35
gatsby-plugin-react-helmet: ^3.1.21 => 3.1.22
gatsby-plugin-sass: ^2.1.28 => 2.1.29
gatsby-plugin-sharp: ^2.4.3 => 2.4.5
gatsby-source-filesystem: ^2.1.46 => 2.1.48
gatsby-source-graphql: ^2.1.33 => 2.1.33
gatsby-transformer-sharp: ^2.3.13 => 2.3.14
npmGlobalPackages:
gatsby-cli: 2.9.0
When using this plugin, you cannot delete pages with incremental builds anymore. I guess it's because the copy
doesn't remove files that are missing in the source folder, but only copies new pages or overwrites existing ones.
Some notes about this plugin
Due to some migration of routing rules, we had a need for this plugin at the beginning of our project. Now that the migration phase is over we removed it. After we removed the plugin, we figured out that the plugin had a very negative impact on incremental build and deployment times. Those are now reduced by over 50%! This is not an issue with smaller projects, but if you have a lot of pages (>10k pages) I would not recommend to use it.
This plugin is exactly what I need but I cannot get it to work. I have followed the README and this is my gatsby-config.js
module.exports = {
siteMetadata: {
title: 'My page',
},
prefixPath: 'custom_asset_folder',
plugins: [
'gatsby-plugin-react-helmet',
'gatsby-plugin-material-ui',
'gatsby-plugin-emotion',
{
resolve: 'gatsby-plugin-asset-path',
},
],
}
When I run gatsby build
I get a config validation error.
I guessed that this may have been down to a typo as the Gatsby docs has pathPrefix
rather than prefixPath
https://next.gatsbyjs.org/docs/gatsby-config/#pathPrefix
I tried changing that key but still got an error.
Error: ENOENT: no such file or directory, stat 'public/sitemap.xml'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.