Skip to content

Commit

Permalink
feat: fetchImageSize - get dimensions on server-side!!!
Browse files Browse the repository at this point in the history
Co-authored-by:
Federico Brigante <me@fregante.com>
image-size/image-size#258 (comment)
  • Loading branch information
nickadamson committed Nov 4, 2022
1 parent a2f12de commit 1604311
Show file tree
Hide file tree
Showing 6 changed files with 568 additions and 398 deletions.
24 changes: 24 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const webpack = require("webpack");

module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
Expand All @@ -15,4 +17,26 @@ module.exports = {
core: {
builder: "webpack5",
},
webpackFinal: async (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
buffer: require.resolve("buffer/"),
fs: false,
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
stream: require.resolve("stream-browserify"),
};

config.plugins = [
...config.plugins,
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
];

console.log(config.plugins);
return config;
},
};
22 changes: 22 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const webpack = require("webpack");
module.exports = {
reactStrictMode: true,
images: {
Expand All @@ -10,4 +11,25 @@ module.exports = {
},
],
},
webpack5: true,
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
buffer: require.resolve("buffer/"),
fs: false,
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
stream: require.resolve("stream-browserify"),
};
config.plugins = [
...config.plugins,
// Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
];

return config;
},
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@
},
"dependencies": {
"@emotion/react": "^11.10.5",
"buffer": "^6.0.3",
"https-browserify": "^1.0.0",
"image-size": "^1.0.2",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@commitlint/cli": "17.1.0",
"@commitlint/config-conventional": "17.1.0",
"@emotion/jest": "^11.10.5",
"@storybook/addon-actions": "^6.5.13",
"@storybook/addon-essentials": "^6.5.13",
Expand Down

0 comments on commit 1604311

Please sign in to comment.