Skip to content

Commit 8f81a6b

Browse files
committed
Add examples, starting with webpack
1 parent f97a755 commit 8f81a6b

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
examples/**/node_modules

examples/webpack/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!dist
2+
dist/*.js

examples/webpack/dist/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>webpack Example</title>
6+
<script src="main.js"></script>
7+
</head>
8+
9+
<body>
10+
</body>
11+
12+
</html>

examples/webpack/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "js-cookie-webpack-example",
3+
"version": "1.0.0",
4+
"description": "",
5+
"private": true,
6+
"scripts": {
7+
"start": "node server.js",
8+
"build": "npx webpack",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"keywords": [],
12+
"author": "",
13+
"license": "ISC",
14+
"devDependencies": {
15+
"node-static": "^0.7.11",
16+
"webpack": "^4.41.0",
17+
"webpack-cli": "^3.3.9"
18+
},
19+
"dependencies": {}
20+
}

examples/webpack/server.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var nodeStatic = require('node-static')
2+
var file = new nodeStatic.Server('./dist')
3+
var port = 8080
4+
5+
require('http')
6+
.createServer(function (request, response) {
7+
request
8+
.addListener('end', function () {
9+
file.serve(request, response)
10+
})
11+
.resume()
12+
})
13+
.listen(port)
14+
15+
console.log(`Example available at http://localhost:${port}`)

examples/webpack/src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Cookies from 'js-cookie'
2+
3+
Cookies.set('test', 'example')

0 commit comments

Comments
 (0)