adds bundling with rollup
This commit is contained in:
parent
6bccb9bccd
commit
76a5e004f2
|
|
@ -17,6 +17,6 @@
|
|||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<web-app></web-app>
|
||||
<script type="module" src="/index.js"></script>
|
||||
<script type="module" src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
|
|
@ -18,8 +18,8 @@
|
|||
"start": "node app/server.js",
|
||||
"dev": "npm-run-all --parallel start dev:frontend",
|
||||
"dev:frontend": "snowpack dev",
|
||||
"build": "snowpack build",
|
||||
"build:watch": "snowpack build --watch",
|
||||
"build": "rollup -c",
|
||||
"build:watch": "rollup -cw",
|
||||
"test": "uvu"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
|
|
@ -42,7 +42,11 @@
|
|||
"@babel/eslint-parser": "^7.16.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.16.4",
|
||||
"@babel/preset-env": "^7.16.4",
|
||||
"@rollup/plugin-babel": "^5.3.0",
|
||||
"@rollup/plugin-commonjs": "^21.0.1",
|
||||
"@rollup/plugin-node-resolve": "^13.0.6",
|
||||
"@snowpack/plugin-babel": "^2.1.7",
|
||||
"@web/rollup-plugin-html": "^1.10.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
|
|
@ -53,6 +57,10 @@
|
|||
"http2-proxy": "^5.0.53",
|
||||
"markdownlint-cli": "^0.30.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rollup": "^2.60.1",
|
||||
"rollup-plugin-minify-html-literals": "^1.2.6",
|
||||
"rollup-plugin-summary": "^1.3.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"simple-git-hooks": "^2.7.0",
|
||||
"snowpack": "^3.8.8",
|
||||
"uvu": "^0.5.2"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
// Import rollup plugins
|
||||
import html from '@web/rollup-plugin-html'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import { babel } from '@rollup/plugin-babel'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
import minifyHTML from 'rollup-plugin-minify-html-literals'
|
||||
import summary from 'rollup-plugin-summary'
|
||||
|
||||
// Configure an instance of @web/rollup-plugin-html
|
||||
const htmlPlugin = html({
|
||||
rootDir: './app/client',
|
||||
flattenOutput: false
|
||||
})
|
||||
|
||||
export default {
|
||||
// Entry point for application build; can specify a glob to build multiple
|
||||
// HTML files for non-SPA app
|
||||
input: 'index.html',
|
||||
plugins: [
|
||||
htmlPlugin,
|
||||
// transpile decorators so we can use the upcoming ES decorator syntax
|
||||
babel({
|
||||
babelrc: true,
|
||||
babelHelpers: 'bundled'
|
||||
}),
|
||||
// convert modules with commonJS syntax to ESM
|
||||
commonjs(),
|
||||
// resolve bare module specifiers to relative paths
|
||||
resolve(),
|
||||
// minify HTML template literals
|
||||
minifyHTML(),
|
||||
// minify JS
|
||||
terser({
|
||||
ecma: 2020,
|
||||
module: true,
|
||||
warnings: true,
|
||||
mangle: {
|
||||
properties: {
|
||||
regex: /^__/
|
||||
}
|
||||
}
|
||||
}),
|
||||
summary()
|
||||
],
|
||||
output:
|
||||
{
|
||||
format: 'es',
|
||||
chunkFileNames: '[name]-[hash].js',
|
||||
entryFileNames: '[name]-[hash].js',
|
||||
dir: 'build'
|
||||
},
|
||||
preserveEntrySignatures: false
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ export default {
|
|||
'./app/client': { url: '/' }
|
||||
},
|
||||
plugins: ['@snowpack/plugin-babel'],
|
||||
mode: 'development',
|
||||
packageOptions: {
|
||||
rollup: {
|
||||
plugins: [
|
||||
|
|
@ -28,6 +29,13 @@ export default {
|
|||
buildOptions: {
|
||||
out: 'build'
|
||||
},
|
||||
optimize: {
|
||||
bundle: true,
|
||||
treeshake: true,
|
||||
minify: false,
|
||||
target: 'es2020',
|
||||
sourcemap: false
|
||||
},
|
||||
// add a proxy for websocket requests for the dev setting
|
||||
routes: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue