-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…999) Using rollup as building tool in Web components projects
- Loading branch information
Showing
3 changed files
with
109 additions
and
86 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
90 changes: 90 additions & 0 deletions
90
packages/cli/templates/webcomponents/igc-ts/projects/_base/files/rollup.config.mjs
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,90 @@ | ||
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import babel from '@rollup/plugin-babel'; | ||
import copy from 'rollup-plugin-copy-assets'; | ||
import { rollupPluginHTML as html } from '@web/rollup-plugin-html'; | ||
import { importMetaAssets } from '@web/rollup-plugin-import-meta-assets'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import { generateSW } from 'rollup-plugin-workbox'; | ||
import path from 'path'; | ||
|
||
export default { | ||
input: 'index.html', | ||
output: { | ||
entryFileNames: '[hash].js', | ||
chunkFileNames: '[hash].js', | ||
assetFileNames: '[hash][extname]', | ||
format: 'es', | ||
dir: 'dist', | ||
}, | ||
preserveEntrySignatures: false, | ||
|
||
plugins: [ | ||
copy({ | ||
assets: [ | ||
'src/assets', | ||
], | ||
}), | ||
/** Enable using HTML as rollup entrypoint */ | ||
html({ | ||
minify: true, | ||
injectServiceWorker: true, | ||
serviceWorkerPath: 'dist/sw.js', | ||
}), | ||
/** Resolve bare module imports */ | ||
nodeResolve(), | ||
/** Minify JS */ | ||
terser(), | ||
/** Bundle assets references via import.meta.url */ | ||
importMetaAssets(), | ||
/** Compile JS to a lower language target */ | ||
babel.babel({ | ||
babelHelpers: 'bundled', | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: [ | ||
'last 3 Chrome major versions', | ||
'last 3 Firefox major versions', | ||
'last 3 Edge major versions', | ||
'last 3 Safari major versions', | ||
], | ||
modules: false, | ||
bugfixes: true, | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
[ | ||
'babel-plugin-template-html-minifier', | ||
{ | ||
modules: { lit: ['html', { name: 'css', encapsulation: 'style' }] }, | ||
failOnError: false, | ||
strictCSS: true, | ||
htmlMinifier: { | ||
collapseWhitespace: true, | ||
conservativeCollapse: true, | ||
removeComments: true, | ||
caseSensitive: true, | ||
minifyCSS: true, | ||
}, | ||
}, | ||
], | ||
], | ||
}), | ||
/** Create and inject a service worker */ | ||
generateSW({ | ||
globIgnores: ['polyfills/*.js', 'nomodule-*.js'], | ||
navigateFallback: '/index.html', | ||
// where to output the generated sw | ||
swDest: path.join('dist', 'sw.js'), | ||
// directory to match patterns against to be precached | ||
globDirectory: path.join('dist'), | ||
// cache any html js and css by default | ||
globPatterns: ['**/*.{html,js,css,webmanifest}'], | ||
skipWaiting: true, | ||
clientsClaim: true, | ||
runtimeCaching: [{ urlPattern: 'polyfills/*.js', handler: 'CacheFirst' }], | ||
}), | ||
], | ||
}; |
67 changes: 0 additions & 67 deletions
67
packages/cli/templates/webcomponents/igc-ts/projects/_base/files/webpack.config.mjs
This file was deleted.
Oops, something went wrong.