@cocreate/indexeddb 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +3 -3
- package/.github/workflows/automated.yml +95 -95
- package/.github/workflows/manual.yml +44 -44
- package/CHANGELOG.md +891 -884
- package/CONTRIBUTING.md +96 -96
- package/CoCreate.config.js +26 -26
- package/LICENSE +21 -21
- package/README.md +84 -84
- package/demo/index.html +20 -20
- package/docs/index.html +254 -254
- package/package.json +67 -67
- package/release.config.js +21 -21
- package/src/index.js +1194 -1194
- package/test/collections.js +33 -33
- package/test/databases.js +29 -29
- package/test/documents.js +63 -63
- package/test/index.html +25 -25
- package/test/indexes.js +35 -35
- package/webpack.config.js +84 -84
package/test/collections.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
async function testCollections() {
|
|
2
|
-
if (!('indexedDB' in window)) {
|
|
3
|
-
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
-
return;
|
|
5
|
-
} else {
|
|
6
|
-
|
|
7
|
-
let createCollection = await CoCreate.indexeddb.createCollection({
|
|
8
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2']
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
console.log('createCollection', createCollection)
|
|
13
|
-
|
|
14
|
-
let readCollection = await CoCreate.indexeddb.readCollection({
|
|
15
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
|
-
})
|
|
17
|
-
console.log('readCollection', readCollection)
|
|
18
|
-
|
|
19
|
-
let updateCollection = await CoCreate.indexeddb.updateCollection({
|
|
20
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
21
|
-
collection: {testCollection: 'testCollectionA'}
|
|
22
|
-
})
|
|
23
|
-
console.log('updateCollection', updateCollection)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let deleteCollection = await CoCreate.indexeddb.deleteCollection({
|
|
27
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
28
|
-
collection: ['testCollectionA', 'testCollection1', 'testCollection2']
|
|
29
|
-
})
|
|
30
|
-
console.log('deleteCollection', deleteCollection)
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
async function testCollections() {
|
|
2
|
+
if (!('indexedDB' in window)) {
|
|
3
|
+
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
+
return;
|
|
5
|
+
} else {
|
|
6
|
+
|
|
7
|
+
let createCollection = await CoCreate.indexeddb.createCollection({
|
|
8
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2']
|
|
10
|
+
|
|
11
|
+
})
|
|
12
|
+
console.log('createCollection', createCollection)
|
|
13
|
+
|
|
14
|
+
let readCollection = await CoCreate.indexeddb.readCollection({
|
|
15
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
|
+
})
|
|
17
|
+
console.log('readCollection', readCollection)
|
|
18
|
+
|
|
19
|
+
let updateCollection = await CoCreate.indexeddb.updateCollection({
|
|
20
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
21
|
+
collection: {testCollection: 'testCollectionA'}
|
|
22
|
+
})
|
|
23
|
+
console.log('updateCollection', updateCollection)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
let deleteCollection = await CoCreate.indexeddb.deleteCollection({
|
|
27
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
28
|
+
collection: ['testCollectionA', 'testCollection1', 'testCollection2']
|
|
29
|
+
})
|
|
30
|
+
console.log('deleteCollection', deleteCollection)
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
package/test/databases.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
async function testDatabases() {
|
|
2
|
-
if (!('indexedDB' in window)) {
|
|
3
|
-
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
-
return;
|
|
5
|
-
} else {
|
|
6
|
-
let createDatabase = await CoCreate.indexeddb.createDatabase({
|
|
7
|
-
database: 'testDB',
|
|
8
|
-
})
|
|
9
|
-
console.log('createDatabase', createDatabase)
|
|
10
|
-
|
|
11
|
-
let readDatabase = await CoCreate.indexeddb.readDatabase({
|
|
12
|
-
database: 'testDB',
|
|
13
|
-
})
|
|
14
|
-
console.log('readDatabase', readDatabase)
|
|
15
|
-
|
|
16
|
-
let updateDatabase = await CoCreate.indexeddb.updateDatabase({
|
|
17
|
-
database: {testDB: 'testDatabase1'}
|
|
18
|
-
})
|
|
19
|
-
console.log('updateDatabase', updateDatabase)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
|
|
23
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
24
|
-
})
|
|
25
|
-
console.log('deleteDatabase', deleteDatabase)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
async function testDatabases() {
|
|
2
|
+
if (!('indexedDB' in window)) {
|
|
3
|
+
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
+
return;
|
|
5
|
+
} else {
|
|
6
|
+
let createDatabase = await CoCreate.indexeddb.createDatabase({
|
|
7
|
+
database: 'testDB',
|
|
8
|
+
})
|
|
9
|
+
console.log('createDatabase', createDatabase)
|
|
10
|
+
|
|
11
|
+
let readDatabase = await CoCreate.indexeddb.readDatabase({
|
|
12
|
+
database: 'testDB',
|
|
13
|
+
})
|
|
14
|
+
console.log('readDatabase', readDatabase)
|
|
15
|
+
|
|
16
|
+
let updateDatabase = await CoCreate.indexeddb.updateDatabase({
|
|
17
|
+
database: {testDB: 'testDatabase1'}
|
|
18
|
+
})
|
|
19
|
+
console.log('updateDatabase', updateDatabase)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
|
|
23
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
24
|
+
})
|
|
25
|
+
console.log('deleteDatabase', deleteDatabase)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
}
|
package/test/documents.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
async function testDocuments() {
|
|
2
|
-
if (!('indexedDB' in window)) {
|
|
3
|
-
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
-
return;
|
|
5
|
-
} else {
|
|
6
|
-
|
|
7
|
-
let createDocument = await CoCreate.indexeddb.createDocument({
|
|
8
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
10
|
-
document: {
|
|
11
|
-
organization_id: '5ff747727005da1c272740ab',
|
|
12
|
-
'books.action.title': 'matr',
|
|
13
|
-
sports: {basketball: {teams: ['bulls']}}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
console.log('createDocument', createDocument)
|
|
18
|
-
let _id = createDocument.document[0]._id
|
|
19
|
-
|
|
20
|
-
let readDocument = await CoCreate.indexeddb.readDocument({
|
|
21
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
23
|
-
document: {
|
|
24
|
-
_id,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
console.log('readDocument', readDocument)
|
|
29
|
-
|
|
30
|
-
let updateDocument = await CoCreate.indexeddb.updateDocument({
|
|
31
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
32
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
33
|
-
document: {
|
|
34
|
-
_id,
|
|
35
|
-
'books.action.title': 'matr',
|
|
36
|
-
sports: {basketball: {teams: ['lakers']}}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
console.log('updateDocument', updateDocument)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let deleteDocument = await CoCreate.indexeddb.deleteDocument({
|
|
44
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
45
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
46
|
-
// document: {
|
|
47
|
-
// _id
|
|
48
|
-
// }
|
|
49
|
-
filter: {
|
|
50
|
-
query: [
|
|
51
|
-
{name: 'organization_id', value: "5ff747727005da1c272740ab"}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
console.log('deleteDocument', deleteDocument)
|
|
58
|
-
|
|
59
|
-
// let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
|
|
60
|
-
// database: ['testDB', 'testDB1', 'testDB2'],
|
|
61
|
-
// })
|
|
62
|
-
// console.log('deleteDatabase', deleteDatabase)
|
|
63
|
-
}
|
|
1
|
+
async function testDocuments() {
|
|
2
|
+
if (!('indexedDB' in window)) {
|
|
3
|
+
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
+
return;
|
|
5
|
+
} else {
|
|
6
|
+
|
|
7
|
+
let createDocument = await CoCreate.indexeddb.createDocument({
|
|
8
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
10
|
+
document: {
|
|
11
|
+
organization_id: '5ff747727005da1c272740ab',
|
|
12
|
+
'books.action.title': 'matr',
|
|
13
|
+
sports: {basketball: {teams: ['bulls']}}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
})
|
|
17
|
+
console.log('createDocument', createDocument)
|
|
18
|
+
let _id = createDocument.document[0]._id
|
|
19
|
+
|
|
20
|
+
let readDocument = await CoCreate.indexeddb.readDocument({
|
|
21
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
23
|
+
document: {
|
|
24
|
+
_id,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
})
|
|
28
|
+
console.log('readDocument', readDocument)
|
|
29
|
+
|
|
30
|
+
let updateDocument = await CoCreate.indexeddb.updateDocument({
|
|
31
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
32
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
33
|
+
document: {
|
|
34
|
+
_id,
|
|
35
|
+
'books.action.title': 'matr',
|
|
36
|
+
sports: {basketball: {teams: ['lakers']}}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
})
|
|
40
|
+
console.log('updateDocument', updateDocument)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
let deleteDocument = await CoCreate.indexeddb.deleteDocument({
|
|
44
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
45
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
46
|
+
// document: {
|
|
47
|
+
// _id
|
|
48
|
+
// }
|
|
49
|
+
filter: {
|
|
50
|
+
query: [
|
|
51
|
+
{name: 'organization_id', value: "5ff747727005da1c272740ab"}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
console.log('deleteDocument', deleteDocument)
|
|
58
|
+
|
|
59
|
+
// let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
|
|
60
|
+
// database: ['testDB', 'testDB1', 'testDB2'],
|
|
61
|
+
// })
|
|
62
|
+
// console.log('deleteDatabase', deleteDatabase)
|
|
63
|
+
}
|
|
64
64
|
}
|
package/test/index.html
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<link
|
|
8
|
-
rel="icon"
|
|
9
|
-
href="https://cdn.cocreate.app/favicon.ico"
|
|
10
|
-
type="image/ico"
|
|
11
|
-
sizes="16x16" />
|
|
12
|
-
<title>indexeddb | CoCreateJS</title>
|
|
13
|
-
<link rel="manifest" href="/manifest.webmanifest" />
|
|
14
|
-
</head>
|
|
15
|
-
|
|
16
|
-
<body>
|
|
17
|
-
<!-- <script src="../../../CoCreateJS/dist/CoCreate.js"></script> -->
|
|
18
|
-
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
19
|
-
<!-- <script src="../dist/CoCreate-indexeddb.js"></script> -->
|
|
20
|
-
<script src="./databases.js"></script>
|
|
21
|
-
<script src="./collections.js"></script>
|
|
22
|
-
<script src="./indexes.js"></script>
|
|
23
|
-
<script src="./documents.js"></script>
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<link
|
|
8
|
+
rel="icon"
|
|
9
|
+
href="https://cdn.cocreate.app/favicon.ico"
|
|
10
|
+
type="image/ico"
|
|
11
|
+
sizes="16x16" />
|
|
12
|
+
<title>indexeddb | CoCreateJS</title>
|
|
13
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
14
|
+
</head>
|
|
15
|
+
|
|
16
|
+
<body>
|
|
17
|
+
<!-- <script src="../../../CoCreateJS/dist/CoCreate.js"></script> -->
|
|
18
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
19
|
+
<!-- <script src="../dist/CoCreate-indexeddb.js"></script> -->
|
|
20
|
+
<script src="./databases.js"></script>
|
|
21
|
+
<script src="./collections.js"></script>
|
|
22
|
+
<script src="./indexes.js"></script>
|
|
23
|
+
<script src="./documents.js"></script>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/test/indexes.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
async function testIndexes() {
|
|
2
|
-
if (!('indexedDB' in window)) {
|
|
3
|
-
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
-
return;
|
|
5
|
-
} else {
|
|
6
|
-
let createIndexes = await CoCreate.indexeddb.createIndex({
|
|
7
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
8
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
9
|
-
index: 'testIndexes'
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
console.log('createIndexes', createIndexes)
|
|
13
|
-
|
|
14
|
-
let readIndexes = await CoCreate.indexeddb.readIndex({
|
|
15
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2']
|
|
17
|
-
})
|
|
18
|
-
console.log('readIndexes', readIndexes)
|
|
19
|
-
|
|
20
|
-
let updateIndexes = await CoCreate.indexeddb.updateIndex({
|
|
21
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
23
|
-
index: {testIndexes: 'testIndexes1'}
|
|
24
|
-
})
|
|
25
|
-
console.log('updateIndexes', updateIndexes)
|
|
26
|
-
|
|
27
|
-
let deleteIndexes = await CoCreate.indexeddb.deleteIndex({
|
|
28
|
-
database: ['testDB', 'testDB1', 'testDB2'],
|
|
29
|
-
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
30
|
-
index: 'testIndexes1'
|
|
31
|
-
})
|
|
32
|
-
console.log('deleteIndexes', deleteIndexes)
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
async function testIndexes() {
|
|
2
|
+
if (!('indexedDB' in window)) {
|
|
3
|
+
console.log("This browser doesn't support IndexedDB.");
|
|
4
|
+
return;
|
|
5
|
+
} else {
|
|
6
|
+
let createIndexes = await CoCreate.indexeddb.createIndex({
|
|
7
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
8
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
9
|
+
index: 'testIndexes'
|
|
10
|
+
|
|
11
|
+
})
|
|
12
|
+
console.log('createIndexes', createIndexes)
|
|
13
|
+
|
|
14
|
+
let readIndexes = await CoCreate.indexeddb.readIndex({
|
|
15
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2']
|
|
17
|
+
})
|
|
18
|
+
console.log('readIndexes', readIndexes)
|
|
19
|
+
|
|
20
|
+
let updateIndexes = await CoCreate.indexeddb.updateIndex({
|
|
21
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
23
|
+
index: {testIndexes: 'testIndexes1'}
|
|
24
|
+
})
|
|
25
|
+
console.log('updateIndexes', updateIndexes)
|
|
26
|
+
|
|
27
|
+
let deleteIndexes = await CoCreate.indexeddb.deleteIndex({
|
|
28
|
+
database: ['testDB', 'testDB1', 'testDB2'],
|
|
29
|
+
collection: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
30
|
+
index: 'testIndexes1'
|
|
31
|
+
})
|
|
32
|
+
console.log('deleteIndexes', deleteIndexes)
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
package/webpack.config.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
-
let isProduction = process.env.NODE_ENV === "production"
|
|
5
|
-
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
entry: {
|
|
9
|
-
"CoCreate-indexeddb": "./src/index.js",
|
|
10
|
-
},
|
|
11
|
-
output: {
|
|
12
|
-
path: path.resolve(__dirname, "dist"),
|
|
13
|
-
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
-
libraryTarget: "umd",
|
|
15
|
-
libraryExport: "default",
|
|
16
|
-
library: ["CoCreate", "indexeddb"],
|
|
17
|
-
globalObject: "this",
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
plugins: [
|
|
21
|
-
new CleanWebpackPlugin(),
|
|
22
|
-
new MiniCssExtractPlugin({
|
|
23
|
-
filename: "[name].css",
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
// Default mode for Webpack is production.
|
|
27
|
-
// Depending on mode Webpack will apply different things
|
|
28
|
-
// on final bundle. For now we don't need production's JavaScript
|
|
29
|
-
// minifying and other thing so let's set mode to development
|
|
30
|
-
mode: isProduction ? "production" : "development",
|
|
31
|
-
module: {
|
|
32
|
-
rules: [
|
|
33
|
-
{
|
|
34
|
-
test: /.js$/,
|
|
35
|
-
exclude: /(node_modules)/,
|
|
36
|
-
use: {
|
|
37
|
-
loader: "babel-loader",
|
|
38
|
-
options: {
|
|
39
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
test: /.css$/i,
|
|
45
|
-
use: [
|
|
46
|
-
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
47
|
-
"file-loader",
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// add source map
|
|
54
|
-
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
55
|
-
|
|
56
|
-
optimization: {
|
|
57
|
-
minimize: true,
|
|
58
|
-
minimizer: [
|
|
59
|
-
new TerserPlugin({
|
|
60
|
-
extractComments: true,
|
|
61
|
-
// cache: true,
|
|
62
|
-
parallel: true,
|
|
63
|
-
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
64
|
-
terserOptions: {
|
|
65
|
-
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
66
|
-
// extractComments: 'all',
|
|
67
|
-
compress: {
|
|
68
|
-
drop_console: true,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
],
|
|
73
|
-
splitChunks: {
|
|
74
|
-
chunks: "all",
|
|
75
|
-
minSize: 200,
|
|
76
|
-
// maxSize: 99999,
|
|
77
|
-
//minChunks: 1,
|
|
78
|
-
|
|
79
|
-
cacheGroups: {
|
|
80
|
-
defaultVendors: false,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
}
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
+
let isProduction = process.env.NODE_ENV === "production"
|
|
5
|
+
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
entry: {
|
|
9
|
+
"CoCreate-indexeddb": "./src/index.js",
|
|
10
|
+
},
|
|
11
|
+
output: {
|
|
12
|
+
path: path.resolve(__dirname, "dist"),
|
|
13
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
+
libraryTarget: "umd",
|
|
15
|
+
libraryExport: "default",
|
|
16
|
+
library: ["CoCreate", "indexeddb"],
|
|
17
|
+
globalObject: "this",
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
plugins: [
|
|
21
|
+
new CleanWebpackPlugin(),
|
|
22
|
+
new MiniCssExtractPlugin({
|
|
23
|
+
filename: "[name].css",
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
// Default mode for Webpack is production.
|
|
27
|
+
// Depending on mode Webpack will apply different things
|
|
28
|
+
// on final bundle. For now we don't need production's JavaScript
|
|
29
|
+
// minifying and other thing so let's set mode to development
|
|
30
|
+
mode: isProduction ? "production" : "development",
|
|
31
|
+
module: {
|
|
32
|
+
rules: [
|
|
33
|
+
{
|
|
34
|
+
test: /.js$/,
|
|
35
|
+
exclude: /(node_modules)/,
|
|
36
|
+
use: {
|
|
37
|
+
loader: "babel-loader",
|
|
38
|
+
options: {
|
|
39
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
test: /.css$/i,
|
|
45
|
+
use: [
|
|
46
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
47
|
+
"file-loader",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
// add source map
|
|
54
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
55
|
+
|
|
56
|
+
optimization: {
|
|
57
|
+
minimize: true,
|
|
58
|
+
minimizer: [
|
|
59
|
+
new TerserPlugin({
|
|
60
|
+
extractComments: true,
|
|
61
|
+
// cache: true,
|
|
62
|
+
parallel: true,
|
|
63
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
64
|
+
terserOptions: {
|
|
65
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
66
|
+
// extractComments: 'all',
|
|
67
|
+
compress: {
|
|
68
|
+
drop_console: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
splitChunks: {
|
|
74
|
+
chunks: "all",
|
|
75
|
+
minSize: 200,
|
|
76
|
+
// maxSize: 99999,
|
|
77
|
+
//minChunks: 1,
|
|
78
|
+
|
|
79
|
+
cacheGroups: {
|
|
80
|
+
defaultVendors: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|