Skip to content

Commit 4e4f0c5

Browse files
committed
feat: initial commit
0 parents  commit 4e4f0c5

18 files changed

+10306
-0
lines changed

.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:prettier/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaVersion": 13,
14+
"sourceType": "module"
15+
},
16+
"plugins": ["@typescript-eslint", "prettier"]
17+
}

.github/workflows/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: build package and run tests
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'package.json'
11+
- 'tsconfig.json'
12+
- 'tsconfig.build.json'
13+
- 'src/**'
14+
- '.github/workflows/main.yml'
15+
pull_request:
16+
branches: [main]
17+
18+
jobs:
19+
test:
20+
name: main
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
node-version: [16.x]
26+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Use Node.js ${{ matrix.node-version }}
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
cache: 'npm'
35+
- name: Install
36+
run: npm install
37+
- name: Test
38+
run: npm run test
39+
- name: Build
40+
run: npm run build
41+
- name: Publish (npm dry run)
42+
run: npm pack --dry-run

.github/workflows/publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://github.com/marketplace/actions/npm-publish
2+
name: publish
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version: 16
17+
registry-url: https://registry.npmjs.org/
18+
19+
- run: npm ci
20+
21+
- run: npm run build
22+
23+
# - run: npm pack --dry-run
24+
25+
- run: npm publish --access public
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Custom
2+
.husky/_/*
3+
.DS_Store
4+
*.gitignore.*
5+
dist/
6+
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# Diagnostic reports (https://nodejs.org/api/report.html)
16+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17+
18+
# Runtime data
19+
pids
20+
*.pid
21+
*.seed
22+
*.pid.lock
23+
24+
# Directory for instrumented libs generated by jscoverage/JSCover
25+
lib-cov
26+
27+
# Coverage directory used by tools like istanbul
28+
coverage
29+
*.lcov
30+
31+
# nyc test coverage
32+
.nyc_output
33+
34+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35+
.grunt
36+
37+
# Bower dependency directory (https://bower.io/)
38+
bower_components
39+
40+
# node-waf configuration
41+
.lock-wscript
42+
43+
# Compiled binary addons (https://nodejs.org/api/addons.html)
44+
build/Release
45+
46+
# Dependency directories
47+
node_modules/
48+
jspm_packages/
49+
50+
# TypeScript v1 declaration files
51+
typings/
52+
53+
# TypeScript cache
54+
*.tsbuildinfo
55+
56+
# Optional npm cache directory
57+
.npm
58+
59+
# Optional eslint cache
60+
.eslintcache
61+
62+
# Microbundle cache
63+
.rpt2_cache/
64+
.rts2_cache_cjs/
65+
.rts2_cache_es/
66+
.rts2_cache_umd/
67+
68+
# Optional REPL history
69+
.node_repl_history
70+
71+
# Output of 'npm pack'
72+
*.tgz
73+
74+
# Yarn Integrity file
75+
.yarn-integrity
76+
77+
# dotenv environment variables file
78+
.env
79+
.env.test
80+
81+
# parcel-bundler cache (https://parceljs.org/)
82+
.cache
83+
84+
# Next.js build output
85+
.next
86+
87+
# Nuxt.js build / generate output
88+
.nuxt
89+
90+
# Gatsby files
91+
.cache/
92+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
93+
# https://nextjs.org/blog/next-9-1#public-directory-support
94+
# public
95+
96+
# vuepress build output
97+
.vuepress/dist
98+
99+
# Serverless directories
100+
.serverless/
101+
102+
# FuseBox cache
103+
.fusebox/
104+
105+
# DynamoDB Local files
106+
.dynamodb/
107+
108+
# TernJS port file
109+
.tern-port

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint
5+
npm run test

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": true,
4+
"semi": true,
5+
"singleQuote": true,
6+
"bracketSpacing": true,
7+
"bracketSameLine": false,
8+
"arrowParens": "always"
9+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 lucagoslar
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.

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
## svelte-preprocess-sass-alias-import
2+
3+
🗃 Import external stylesheets with the help of absolute paths.
4+
5+
Though this package might also work in a different environment that uses sass, it should be noted that it serves the [legacy importer](https://sass-lang.com/documentation/js-api/modules#LegacyImporter) used by [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess).
6+
7+
[![build and test](https://github.com/lucagoslar/svelte-preprocess-sass-alias-import/actions/workflows/main.yml/badge.svg)](https://github.com/lucagoslar/svelte-preprocess-sass-alias-import/actions/workflows/main.yml)
8+
9+
## Setup
10+
11+
1. Import `SassAlias` from `svelte-preprocess-sass-alias-import`.
12+
13+
```ts
14+
import { SassAlias } from 'svelte-preprocess-sass-alias-import';
15+
```
16+
17+
2. Instantiate `SassAlias` and pass it an object containing your rules.
18+
19+
```ts
20+
const alias = new SassAlias({
21+
$var: 'src/scss',
22+
@var: ["src", "scss"]
23+
});
24+
```
25+
26+
3. Add and bind the `SassAlias` instance to the project's preprocessor.
27+
(Sample usage with SvelteKit.)
28+
29+
```ts
30+
// svelte.config.js
31+
import preprocess from 'svelte-preprocess';
32+
33+
/** @type {import('@sveltejs/kit').Config} */
34+
const config = {
35+
preprocess: [
36+
preprocess({
37+
sass: {
38+
importer: [alias.resolve.bind(alias)],
39+
},
40+
scss: {
41+
importer: [alias.resolve.bind(alias)],
42+
}, // Use for both sass and or scss
43+
}),
44+
],
45+
46+
kit: {
47+
vite: {
48+
// Only required if you want to import stylesheets into an already imported stylesheet
49+
css: {
50+
preprocessorOptions: {
51+
sass: {
52+
importer: [alias.resolve.bind(alias)],
53+
},
54+
scss: {
55+
importer: [alias.resolve.bind(alias)],
56+
},
57+
},
58+
},
59+
},
60+
},
61+
};
62+
63+
export default config;
64+
```
65+
66+
4. Import files using your predefined aliases.
67+
68+
```svelte
69+
<!-- *.svelte -->
70+
<style lang="scss">
71+
@import "$var/main.scss";
72+
</style>
73+
```
74+
75+
```svelte
76+
<!-- *.svelte -->
77+
<style lang="sass">
78+
@use "@var/main.scss"
79+
</style>
80+
```
81+
82+
```scss
83+
// *.scss
84+
@use '@var/main.scss';
85+
```
86+
87+
## Contribute
88+
89+
Install all (dev-)dependencies by running the following.
90+
91+
```
92+
npm i
93+
```
94+
95+
Make sure [husky](https://github.com/typicode/husky) is being installed too.
96+
97+
```
98+
npm run prepare
99+
```
100+
101+
\
102+
_And off we go …_
103+
104+
Build this project with the following.
105+
106+
```
107+
npm run build
108+
```
109+
110+
Contributions of any kind are very much appreciated.

jest.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { pathsToModuleNameMapper } = require('ts-jest');
2+
const { compilerOptions } = require('./tsconfig');
3+
4+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
5+
module.exports = {
6+
preset: 'ts-jest',
7+
testEnvironment: 'node',
8+
setupFilesAfterEnv: ['jest-extended/all'],
9+
roots: ['./src/'],
10+
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'],
11+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
12+
prefix: '<rootDir>',
13+
}),
14+
};

0 commit comments

Comments
 (0)