mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-21 14:05:08 +00:00
aspirational approach to differential bundling
This commit is contained in:
9
.babelrc
Normal file
9
.babelrc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"presets": ["@babel/preset-env"],
|
||||||
|
"plugins": [
|
||||||
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
|
["@babel/plugin-transform-runtime", {
|
||||||
|
"useESModules": true
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -18,9 +18,15 @@
|
|||||||
"sirv": "^0.2.0"
|
"sirv": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.0.0",
|
||||||
|
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.0.0",
|
||||||
|
"@babel/preset-env": "^7.0.0",
|
||||||
|
"@babel/runtime": "^7.0.0",
|
||||||
"chokidar": "^2.0.4",
|
"chokidar": "^2.0.4",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"rollup": "^0.65.0",
|
"rollup": "^0.65.0",
|
||||||
|
"rollup-plugin-babel": "^4.0.2",
|
||||||
"rollup-plugin-commonjs": "^9.1.6",
|
"rollup-plugin-commonjs": "^9.1.6",
|
||||||
"rollup-plugin-loadz0r": "^0.3.0",
|
"rollup-plugin-loadz0r": "^0.3.0",
|
||||||
"rollup-plugin-node-resolve": "^3.3.0",
|
"rollup-plugin-node-resolve": "^3.3.0",
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import resolve from 'rollup-plugin-node-resolve';
|
|||||||
import replace from 'rollup-plugin-replace';
|
import replace from 'rollup-plugin-replace';
|
||||||
import commonjs from 'rollup-plugin-commonjs';
|
import commonjs from 'rollup-plugin-commonjs';
|
||||||
import svelte from 'rollup-plugin-svelte';
|
import svelte from 'rollup-plugin-svelte';
|
||||||
|
import babel from 'rollup-plugin-babel';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
import config from 'sapper/config/rollup.js';
|
import config from 'sapper/config/rollup.js';
|
||||||
|
|
||||||
const mode = process.env.NODE_ENV;
|
const mode = process.env.NODE_ENV;
|
||||||
const dev = mode === 'development';
|
const dev = mode === 'development';
|
||||||
|
const legacy = process.env.SAPPER_LEGACY_BUILD;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: config.client.input(),
|
input: config.client.input(),
|
||||||
@@ -23,6 +25,15 @@ export default {
|
|||||||
hydratable: true
|
hydratable: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
legacy && babel({
|
||||||
|
extensions: ['.js', '.html'],
|
||||||
|
include: [
|
||||||
|
'app/**',
|
||||||
|
'routes/**'
|
||||||
|
],
|
||||||
|
runtimeHelpers: true
|
||||||
|
}),
|
||||||
|
|
||||||
!dev && terser({
|
!dev && terser({
|
||||||
module: true
|
module: true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,10 +23,9 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
preload({ params, query }) {
|
async preload({ params, query }) {
|
||||||
return this.fetch(`blog.json`).then(r => r.json()).then(posts => {
|
const posts = await this.fetch(`blog.json`).then(r => r.json());
|
||||||
return { posts };
|
return { posts };
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user