Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: bundlesize #43

Merged
merged 6 commits into from
Sep 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ci: bundlesize
resolves #42
damienrobinson committed Sep 6, 2020
commit 6b02ae748a1f8390da510a1c2428270f5f38ffda
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ cache: npm
script:
- npm run lint
# - npm run test
- npm run bundlesize
- npm run generate
- npx semantic-release

9 changes: 9 additions & 0 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files": [
{
"path": "dist/**/*.!(jpg)",
"maxSize": "250 kB",
"compression": "brotli"
}
]
}
41 changes: 41 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@
</template>

<script>
import { shuffle, head } from 'lodash-es'
import { mdiSprout, mdiInformation, mdiStore, mdiDatabase } from '@mdi/js'
// import UserMenu from '@/components/UserMenu.vue'
import LastModified from '@/components/LastModified'
@@ -158,6 +159,46 @@ export default {
},
methods: {
shortHash: (value) => (value ? value.substring(0, 7) : null),
src: require.context(
`~/assets/img/species?resize&size=640&format=webp`,
false,
/\.(png|jpe?g|svg).*$/
),
async ogImage() {
const content = await this.$content('species').fetch()
const { body } = content
const result = shuffle(
body
.filter((item) => item.image)
.map((item) => ({
name: item.species,
image: item.image,
}))
)
return head(result)
},
},
async head() {
const image = await this.ogImage().image
return {
meta: [
{
hid: 'og:image',
property: 'og:image',
content: this.src(`./${image}`).src,
},
{
hid: 'og:image:width',
property: 'og:image:width',
content: this.src(`./${image}`).width,
},
{
hid: 'og:image:height',
property: 'og:image:height',
content: this.src(`./${image}`).height,
},
],
}
},
}
</script>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
"dev": "nuxt-ts",
"build": "nuxt-ts build",
"build:analyze": "npm run build -- --analyze",
"bundlesize": "bundlesize",
"start": "nuxt-ts start",
"serve": "nuxt-ts serve",
"serve:lhci": "npm run start",
2 changes: 1 addition & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ export default {
/\.(png|jpe?g|svg).*$/
),
src: require.context(
`~/assets/img/species?resize&sizes[]=320&sizes[]=600&sizes[]=900&sizes[]=1785&sizes[]=4686&format=webp`,
`~/assets/img/species?resize&sizes[]=320&sizes[]=600&sizes[]=900&sizes[]=1785&sizes[]=4686&placeholder&format=webp`,
false,
/\.(png|jpe?g|svg).*$/
),
3 changes: 1 addition & 2 deletions pages/species/_id.vue
Original file line number Diff line number Diff line change
@@ -350,8 +350,7 @@ export default {
{
hid: 'og:image',
property: 'og:image',
content: !require(`@/assets/img/species/${this.item.image}?resize&sizes[]=1785&placeholder`)
.src,
content: this.src(`./${this.item.image}`).src,
},
{
hid: 'og:image:width',
2 changes: 1 addition & 1 deletion pages/species/index.vue
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ export default {
/\.(png|jpe?g|svg).*$/
),
src: require.context(
`~/assets/img/species?resize&sizes[]=320&sizes[]=640&sizes[]=960&placeholder&placeholderSize=10&format=webp`,
`~/assets/img/species?resize&sizes[]=320&sizes[]=640&sizes[]=960&placeholder&format=webp`,
false,
/\.(png|jpe?g|svg).*$/
),
11 changes: 0 additions & 11 deletions static/README.md

This file was deleted.