Skip to content

Commit 319b41e

Browse files
committed
add webpack entry point example
1 parent 417d48a commit 319b41e

File tree

18 files changed

+329
-1
lines changed

18 files changed

+329
-1
lines changed
9.44 KB
Binary file not shown.

examples/basic/public/favicon.ico

9.44 KB
Binary file not shown.
9.44 KB
Binary file not shown.

examples/styled/public/favicon.ico

9.44 KB
Binary file not shown.

examples/webpack-entry-point/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"]
3+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Webpack entry point
2+
3+
This example is the same as the [basic example](https://github.com/Lemoncode/react-image-focal-point/tree/main/examples/basic), but using the webpack entry point to import the styles from the libray.
4+
5+
## How to apply this feature in your code
6+
7+
Import the library component in your _app_:
8+
9+
```jsx
10+
import { ImageFocalPoint } from '@lemoncode/react-image-focal-point';
11+
12+
const App = () => {
13+
return (
14+
<ImageFocalPoint
15+
src="your-image-src"
16+
onChange={newFocalPoint => {
17+
// Whatever you want to do when the user clicks on the image
18+
}}
19+
/>
20+
);
21+
};
22+
```
23+
24+
Import the library styles in your webpack entry point:
25+
26+
```diff
27+
28+
module.exports = {
29+
// ...
30+
entry: {
31+
index: './index.tsx',
32+
+ vendorStyles: ['@lemoncode/react-image-focal-point/style.css'],
33+
},
34+
// ...
35+
}
36+
37+
```
38+
39+
<a target="_blank" href="https://stackblitz.com/github/Lemoncode/react-image-focal-point/tree/main/examples/webpack-entry-point">
40+
<img
41+
src="https://developer.stackblitz.com/img/open_in_stackblitz.svg"
42+
alt="Edit on StackBlitz"
43+
title="Edit on StackBlitz"
44+
height="36"
45+
/>
46+
</a> <a target="_blank" href="https://codesandbox.io/s/github/Lemoncode/react-image-focal-point/tree/main/examples/webpack-entry-point">
47+
<img
48+
src="https://codesandbox.io/static/img/play-codesandbox.svg"
49+
alt="Edit on StackBlitz"
50+
title="Edit on StackBlitz"
51+
height="36"
52+
/>
53+
</a>

examples/webpack-entry-point/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.css';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Webpack entry point</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
</body>
12+
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "webpack-entry-point-example",
3+
"scripts": {
4+
"start": "webpack serve --open --mode development"
5+
},
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/Lemoncode/react-image-focal-point.git"
9+
},
10+
"author": "Lemoncode",
11+
"homepage": "https://github.com/Lemoncode/react-image-focal-point/tree/main/#readme",
12+
"devDependencies": {
13+
"@babel/cli": "^7.20.7",
14+
"@babel/core": "^7.20.12",
15+
"@babel/preset-env": "^7.20.2",
16+
"@babel/preset-react": "^7.18.6",
17+
"@babel/preset-typescript": "^7.18.6",
18+
"@types/react": "^18.0.28",
19+
"@types/react-dom": "^18.0.11",
20+
"copy-webpack-plugin": "^11.0.0",
21+
"css-loader": "^6.7.3",
22+
"html-webpack-plugin": "^5.5.0",
23+
"style-loader": "^3.3.1",
24+
"typescript": "^4.9.5",
25+
"webpack": "^5.75.0",
26+
"webpack-cli": "^5.0.1",
27+
"webpack-dev-server": "^4.11.1"
28+
},
29+
"dependencies": {
30+
"@lemoncode/react-image-focal-point": "*",
31+
"react": "^18.2.0",
32+
"react-dom": "^18.2.0"
33+
}
34+
}
9.44 KB
Binary file not shown.

0 commit comments

Comments
 (0)