├── .babelrc ├── .circleci ├── comment-artifacts.sh └── config.yml ├── .codecov.yml ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .release-it.json ├── LICENSE ├── README.md ├── commitlint.config.js ├── example ├── App.js ├── constants.js └── index.html ├── package.json ├── src ├── LinariaAsset.js ├── __fixtures__ │ ├── css.js │ ├── index.js │ └── styled.js ├── __tests__ │ └── index.test.js └── index.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "node": "current" 8 | } 9 | } 10 | ], 11 | "@babel/preset-react" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.circleci/comment-artifacts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL="https://callstack-github-bot.herokuapp.com/comment" 4 | LINK="https://$CIRCLE_BUILD_NUM-172142945-gh.circle-artifacts.com/$CIRCLE_NODE_INDEX/coverage/lcov-report/index.html" 5 | TEMPLATE="Hey @{{user.login}}, thank you for your pull request 🤗.\nThe coverage report for this branch can be viewed [here]($LINK)." 6 | 7 | read -r -d '' DATA << EOM 8 | { 9 | "pull_request": "$CIRCLE_PULL_REQUEST", 10 | "template": "$TEMPLATE", 11 | "test": { 12 | "type": "string", 13 | "data": "The coverage report for this branch can be viewed" 14 | }, 15 | "update": true 16 | } 17 | EOM 18 | 19 | curl \ 20 | -H "Content-Type: application/json" \ 21 | -d "$DATA" \ 22 | -X POST $URL 23 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | defaults: &defaults 3 | docker: 4 | - image: circleci/node:10 5 | working_directory: ~/project 6 | jobs: 7 | install-dependencies: 8 | <<: *defaults 9 | steps: 10 | - checkout 11 | - attach_workspace: 12 | at: ~/project 13 | - restore_cache: 14 | keys: 15 | - dependencies-{{ checksum "package.json" }} 16 | - dependencies- 17 | - run: | 18 | yarn install --frozen-lockfile 19 | - save_cache: 20 | key: dependencies-{{ checksum "package.json" }} 21 | paths: node_modules 22 | - persist_to_workspace: 23 | root: . 24 | paths: . 25 | 26 | lint: 27 | <<: *defaults 28 | steps: 29 | - attach_workspace: 30 | at: ~/project 31 | - run: | 32 | yarn lint 33 | 34 | unit-tests: 35 | <<: *defaults 36 | steps: 37 | - attach_workspace: 38 | at: ~/project 39 | - run: | 40 | yarn test --coverage 41 | cat ./coverage/lcov.info | ./node_modules/.bin/codecov 42 | bash .circleci/comment-artifacts.sh 43 | - store_artifacts: 44 | path: coverage 45 | destination: coverage 46 | 47 | build-example: 48 | <<: *defaults 49 | steps: 50 | - attach_workspace: 51 | at: ~/project 52 | - run: | 53 | yarn parcel build example/index.html 54 | - store_artifacts: 55 | path: dist 56 | destination: dist 57 | 58 | workflows: 59 | version: 2 60 | build-and-test: 61 | jobs: 62 | - install-dependencies 63 | - lint: 64 | requires: 65 | - install-dependencies 66 | - unit-tests: 67 | requires: 68 | - install-dependencies 69 | - build-example: 70 | requires: 71 | - install-dependencies 72 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: 70...100 5 | 6 | status: 7 | project: true 8 | patch: true 9 | changes: false 10 | 11 | comment: false 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # we recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | __fixtures__/ 2 | __output__/ 3 | 4 | dist/ 5 | node_modules/ 6 | 7 | .cache/ 8 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | 'extends': '@callstack/eslint-config', 3 | 'rules': 4 | { 5 | 'global-require': 'off', 6 | 'import/no-extraneous-dependencies': 7 | ['error', { 'devDependencies': true }], 8 | 'react-native/no-raw-text': 'off', 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### OS Junk ### 2 | .DS_Store 3 | *~ 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (http://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Typescript v1 declaration files 45 | typings/ 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Optional REPL history 54 | .node_repl_history 55 | 56 | # Output of 'npm pack' 57 | *.tgz 58 | 59 | # Yarn Integrity file 60 | .yarn-integrity 61 | 62 | # dotenv environment variables file 63 | .env 64 | 65 | # generated files 66 | lib/ 67 | dist/ 68 | build/ 69 | 70 | __output__ 71 | 72 | .linaria-cache 73 | .cache 74 | -------------------------------------------------------------------------------- /.release-it.json: -------------------------------------------------------------------------------- 1 | { 2 | "git": { 3 | "commitMessage": "chore: release %s", 4 | "tagName": "v%s" 5 | }, 6 | "npm": { 7 | "publish": true 8 | }, 9 | "github": { 10 | "release": true 11 | }, 12 | "plugins": { 13 | "@release-it/conventional-changelog": { 14 | "preset": "angular" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Callstack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # parcel-plugin-linaria 2 | 3 | [![Build Status][build-badge]][build] 4 | [![Code Coverage][coverage-badge]][coverage] 5 | [![Version][version-badge]][package] 6 | [![MIT License][license-badge]][license] 7 | 8 | [![PRs Welcome][prs-welcome-badge]][prs-welcome] 9 | [![Chat][chat-badge]][chat] 10 | [![Sponsored by Callstack][callstack-badge]][callstack] 11 | 12 | A plugin to use [Linaria](https://github.com/callstack/linaria) with [Parcel](https://parceljs.org/). 13 | 14 | ## Installation 15 | 16 | ```sh 17 | yarn add --dev parcel-plugin-linaria 18 | ``` 19 | 20 | or 21 | 22 | ```sh 23 | npm install --save-dev parcel-plugin-linaria 24 | ``` 25 | 26 | ## Usage 27 | 28 | The plugin works without any extra configuration. See [Linaria's docs](https://github.com/callstack/linaria/blob/master/docs/CONFIGURATION.md) if you want to configure the library. 29 | 30 | ## Limitations 31 | 32 | - CSS source maps are not supported because [Parcel doesn't support them](https://github.com/parcel-bundler/parcel/issues/1824). 33 | - The plugin works by extending Parcel's `JSAsset` due to how Parcel works. Any other plugins which do the same might have conflicts. 34 | 35 | ## License 36 | 37 | MIT License 38 | 39 | ## Made with ❤️ at Callstack 40 | 41 | `parcel-plugin-linaria` is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Callstack](https://callstack.com) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi! 42 | 43 | 44 | [build-badge]: https://img.shields.io/circleci/project/github/callstack/parcel-plugin-linaria/master.svg?style=flat-square 45 | [build]: https://circleci.com/gh/callstack/parcel-plugin-linaria 46 | [coverage-badge]: https://img.shields.io/codecov/c/github/callstack/parcel-plugin-linaria.svg?style=flat-square 47 | [coverage]: https://codecov.io/github/callstack/parcel-plugin-linaria 48 | [version-badge]: https://img.shields.io/npm/v/parcel-plugin-linaria.svg?style=flat-square 49 | [package]: https://www.npmjs.com/package/parcel-plugin-linaria 50 | [license-badge]: https://img.shields.io/npm/l/parcel-plugin-linaria.svg?style=flat-square 51 | [license]: https://opensource.org/licenses/MIT 52 | [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square 53 | [prs-welcome]: http://makeapullrequest.com 54 | [chat-badge]: https://img.shields.io/discord/426714625279524876.svg?style=flat-square&colorB=758ED3 55 | [chat]: https://discord.gg/zwR2Cdh 56 | [callstack-badge]: https://callstack.com/images/callstack-badge.svg 57 | [callstack]: https://callstack.com/open-source/?utm_source=github.com&utm_medium=referral&utm_campaign=linaria&utm_term=readme 58 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { styled } from 'linaria/react'; 4 | 5 | import constants from './constants'; 6 | 7 | const Title = styled.h1` 8 | font-family: ${constants.fontFamily}; 9 | font-size: 18px; 10 | color: ${() => constants.primaryColor}; 11 | `; 12 | 13 | function App() { 14 | return