-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Using this library as typescript module
* also test that it works well with `isolatedModules`
- Loading branch information
Showing
7 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bundle.js | ||
yarn.lock | ||
index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Webpack with Typescript module | ||
|
||
This example shows how to integrate LMC Cookie Consent Manager with Webpack via ESM module using Typescript. | ||
|
||
## How to use | ||
|
||
Execute [npm][npm] or [Yarn][yarn] to bootstrap the example: | ||
|
||
```shell | ||
npm install | ||
# or | ||
yarn | ||
``` | ||
|
||
Then run the `build` script and open `index.html` in your browser. | ||
|
||
[npm]:https://docs.npmjs.com/cli/init | ||
[yarn]:https://yarnpkg.com/lang/en/docs/cli/create/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
|
||
<title>Cookie Consent Manager – module example</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"> | ||
|
||
<link rel="stylesheet" href="../../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead --> | ||
|
||
</head> | ||
<body> | ||
<h1>LMC Cookie Consent Manager</h1> | ||
<script defer src="./bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import LmcCookieConsentManager, { DisplayMode } from '@lmc-eu/cookie-consent-manager'; | ||
|
||
const ccmArgs = { | ||
displayMode: DisplayMode.SOFT, | ||
config: { | ||
cookie_name: 'lmc_ccm_example', | ||
cookie_domain: 'example.com', | ||
cookie_necessary_only_expiration: 30, | ||
} | ||
}; | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
LmcCookieConsentManager('example', ccmArgs); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@lmc-eu/cookie-consent-manager-example-typescript", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"ts-loader": "^9.2.8", | ||
"typescript": "^4.6.2", | ||
"webpack": "^5.63.0", | ||
"webpack-cli": "^4.9.1" | ||
}, | ||
"dependencies": { | ||
"@lmc-eu/cookie-consent-manager": "../../dist" | ||
}, | ||
"scripts": { | ||
"build": "webpack build --config ./webpack.config.js", | ||
"types": "tsc -p ./tsconfig.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./", | ||
"noImplicitAny": true, | ||
"module": "es6", | ||
"target": "es5", | ||
"jsx": "react", | ||
"allowJs": true, | ||
"moduleResolution": "node", | ||
"isolatedModules": true | ||
}, | ||
"include": [ | ||
"./index.ts" | ||
], | ||
"exclude": [ | ||
"./bundle.js" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: './index.ts', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, './'), | ||
filename: 'bundle.js', | ||
}, | ||
}; |