Skip to content

Commit

Permalink
Refactor: Build and rename distribution files
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Oct 19, 2021
1 parent 8c433a2 commit bdb0f89
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 36 deletions.
4 changes: 2 additions & 2 deletions demo/autoload.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="../dist/cookieconsent.css">
<link rel="stylesheet" href="../dist/LmcCookieConsentManager.css">
</head>
<body>

<h1>LMC Cookie Consent Manager Demo</h1>

<script defer src="../dist/index.js"></script>
<script defer src="../dist/autoload.js"></script>

</body>
</html>
4 changes: 2 additions & 2 deletions demo/bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link href="https://fonts.googleapis.com/css2?family=Inter&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="../dist/cookieconsent.css">
<link rel="stylesheet" href="../dist/LmcCookieConsentManager.css">
</head>
<body>

<h1>LMC Cookie Consent Manager Demo</h1>

<script defer src="../dist/bootstrap.js"></script>
<script defer src="../dist/init.js"></script>
<script>
window.addEventListener('load', function(){
initLmcCookieConsentManager();
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"precss": "yarn css:lint",
"css": "yarn css:compile && yarn css:prefix && yarn css:minify",
"css:lint": "stylelint --config .stylelintrc \"src/**/*.scss\" --cache --cache-location .cache/.stylelintcache",
"css:compile": "sass --load-path=node_modules/@lmc-eu/spirit-design-tokens/dist/default/scss src/cookieconsent.scss dist/cookieconsent.css",
"css:compile": "sass --load-path=node_modules/@lmc-eu/spirit-design-tokens/dist/default/scss src/LmcCookieConsentManager.scss dist/LmcCookieConsentManager.css",
"css:prefix": "postcss --config postcss.config.js --replace \"dist/*.css\" \"!dist/*.min.css\"",
"css:minify": "cleancss --format breaksWith=lf --source-map-inline-sources --batch --batch-suffix \".min\" \"dist/*.css\" \"!dist/*.min.css\"",
"test": "yarn css:lint",
"build:js": "node scripts/build.js",
"build": "yarn build:js && yarn build:css",
"format": "yarn format:check",
"format:check": "prettier --list-different 'src/**/*.{js,jsx,ts,tsx,scss}'",
"format:fix": "prettier --write 'src/**/*.{js,jsx,ts,tsx,scss}'"
"format:check": "prettier --list-different 'src/**/*.{js,jsx,ts,tsx,scss}' 'scripts/*'",
"format:fix": "prettier --write 'src/**/*.{js,jsx,ts,tsx,scss}' 'scripts/*'"
},
"dependencies": {
"@lmc-eu/spirit-design-tokens": "^0.2.0",
Expand Down
38 changes: 10 additions & 28 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
const { build } = require('esbuild')
const { build } = require('esbuild');

build({
entryPoints: ['src/autoload.js'],
entryPoints: [
'src/autoload.js',
'src/init.js',
`src/LmcCookieConsentManager.js`,
],
bundle: true,
target: 'es2017',
outfile: 'dist/autoload.js',
outdir: 'dist',
}).catch((error) => {
console.error(error)
process.exit(1)
})

build({
entryPoints: ['src/bootstrap.js'],
bundle: true,
target: 'es2017',
outfile: 'dist/bootstrap.js',
}).catch((error) => {
console.error(error)
process.exit(1)
})

build({
entryPoints: ['src/LmcCookieConsentManager.js'],
bundle: true,
minify: false,
sourcemap: false,
target: 'es2019',
outfile: 'dist/LmcCookieConsentManager.js',
}).catch((error) => {
console.error(error)
process.exit(1)
})
console.error(error);
process.exit(1);
});
File renamed without changes.
2 changes: 1 addition & 1 deletion src/autoload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LmcCookieConsent from './LmcCookieConsentManager';
import LmcCookieConsentManager from './LmcCookieConsentManager';

window.addEventListener('load', function () {
LmcCookieConsentManager();
Expand Down
File renamed without changes.

0 comments on commit bdb0f89

Please sign in to comment.