Skip to content

Commit

Permalink
chore: init
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
danielroe and pi0 committed Jun 22, 2021
0 parents commit bf31f9b
Show file tree
Hide file tree
Showing 28 changed files with 12,999 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
dist
.nuxt
coverage
*.log*
.DS_Store
.code
*.iml
package-lock.json
templates/*
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
extends: ['@nuxtjs/eslint-config-typescript', 'prettier'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
curly: 'off',
'no-empty': 'off',
'no-undef': 'off',
},
}
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Bug report
about: Report a bug report to help us improve the module.
title: ''
labels: bug
assignees: ''

---

### Version
module: <!-- ex: 5.9.0 -->
nuxt: <!-- ex: 2.0.0 -->

### Nuxt configuration
#### [mode](https://nuxtjs.org/api/configuration-mode): <!--universal is the default -->
- [ ] universal
- [ ] spa

### Nuxt configuration
<!--
If relevant, please include the configuration you are using for this module.
For example:
```
```
-->

## Reproduction
> :warning: without a minimal reproduction we wont be able to look into your issue
**Link:**
[ ] https:///codesandbox.io/
[ ] GitHub repository

#### What is expected?
#### What is actually happening?
#### Steps to reproduce
## Additional information
## Checklist
* [ ] I have tested with the latest Nuxt version and the issue still occurs
* [ ] I have tested with the latest module version and the issue still occurs
* [ ] I have searched the issue tracker and this issue hasn't been reported yet

### Steps to reproduce


### What is expected?


### What is actually happening?
<!-- Add any other context or screenshots about the feature request here. -->

### Performance analysis?
<!-- Add any performance metrics or regressions here -->
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Nuxt Community Discord
url: https://discord.nuxtjs.org/
about: Consider asking questions about the module here.
# - name: Documentation
# url: /README.md
# about: Check our documentation before reporting issues or questions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea or enhancement for this project.
title: ''
labels: enhancement
assignees: ''

---

### Is your feature request related to a problem? Please describe.
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

### Describe the solution you'd like to see
<!-- A clear and concise description of what you want to happen. -->

### Describe alternatives you've considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Question
about: Ask a question about the module.
title: ''
labels: question
assignees: ''

---

<!--
**IMPORTANT!**
Please make sure to look for an answer to your question in our documentation before asking a question here.
If you have a general question regarding {{ name }} use Discord `modules` channel. Thanks!
Documentation: {{ docs }}
Nuxt Discord: https://discord.nuxtjs.org/
-->
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [12, 14]

steps:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: checkout
uses: actions/checkout@v2

- name: cache node_modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn

- name: Lint
run: yarn lint:all

- name: Test
run: yarn test

- name: Coverage
uses: codecov/codecov-action@v1
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
*.iml
.idea
*.log*
.nuxt
.vscode
.DS_Store
coverage
dist
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
18 changes: 18 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"git": {
"commitMessage": "chore: release v${version}"
},
"github": {
"release": true,
"releaseName": "v${version}"
},
"npm": {
"skipChecks": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "conventionalcommits",
"infile": "CHANGELOG.md"
}
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# @nuxtjs/critters

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]

> CSS optimization using [critters](https://github.com/GoogleChromeLabs/critters) for [Nuxt](https://nuxtjs.org)
## Features

- Zero-configuration required
- Enables CSS Extraction
- Critical CSS automatically injected to page

## Quick setup

1. Add `@nuxtjs/critters` dependency to your project

```bash
yarn add @nuxtjs/critters # or npm install @nuxtjs/critters
```

2. Add `@nuxtjs/critters` to the `modules` section of `nuxt.config.js`

```js
{
modules: [
'@nuxtjs/critters',
],
}
```

## How it works

Nuxt has a number of ways to optimize your CSS in production:

1. ✅ Nuxt uses [`cssnano`](https://cssnano.co/) at the build step to minify CSS rules
2. 📦 You can enable [`purgecss`](https://github.com/Developmint/nuxt-purgecss) to remove unused CSS rules from your bundle.
3. ✅ with `@nuxtjs/critters` you can now extract CSS files and load them separately, just inlining the CSS necessary to render the page.

## Development

1. Clone this repository
2. Install dependencies using `yarn install`
3. Start development server using `yarn dev`

## License

[MIT License](./LICENSE)

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/critters/latest.svg
[npm-version-href]: https://npmjs.com/package/@nuxtjs/critters

[npm-downloads-src]: https://img.shields.io/npm/dm/@nuxtjs/critters.svg
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/critters

[github-actions-ci-src]: https://github.com/nuxt-community/critters-module/workflows/ci/badge.svg
[github-actions-ci-href]: https://github.com/nuxt-community/critters-module/actions?query=workflow%3Aci

[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/critters-module.svg
[codecov-href]: https://codecov.io/gh/nuxt-community/critters-module

[license-src]: https://img.shields.io/npm/l/@nuxtjs/critters.svg
[license-href]: https://npmjs.com/package/@nuxtjs/critters
4 changes: 4 additions & 0 deletions example/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
modules: ['../src/index.ts'],
css: ['~/styles/global.css'],
}
23 changes: 23 additions & 0 deletions example/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div :class="toggle ? 'sample-class' : 'sample-unused-class'">
some text
<button @click="toggle = !toggle">Toggle class</button>
</div>
</template>

<script>
export default {
data: () => ({
toggle: true
}),
}
</script>

<style>
.sample-class {
background: blue;
}
.sample-unused-class {
background: red;
}
</style>
3 changes: 3 additions & 0 deletions example/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background: darkgoldenrod;
}
3 changes: 3 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../tsconfig.json"
}
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: '@nuxt/test-utils',
collectCoverage: true,
collectCoverageFrom: ['src/**'],
}
3 changes: 3 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.{js,ts,vue}': ['yarn lint']
}
11 changes: 11 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Global settings applied to the whole site.
#
# “base” is the directory to change to before starting build. If you set base:
# that is where we will look for package.json/.nvmrc/etc, not repo root!
# “command” is your build command.
# “publish” is the directory to publish (relative to the root of your repo).

[build]
base = "docs"
command = "yarn && yarn generate"
publish = "dist"

0 comments on commit bf31f9b

Please sign in to comment.