Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
feat: added preprocessed version
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerM committed Oct 24, 2020
1 parent a53b281 commit 8669950
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 506 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@commitlint/config-conventional": "^11.0.0",
"babel-eslint": "^10.1.0",
"concurrently": "^5.3.0",
"eslint": "^7.11.0",
"eslint": "^7.12.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-svelte3": "^2.7.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"sass": "^1.27.0",
"serve": "^11.3.2",
"svelte": "^3.29.4",
"svelte-preprocess": "^4.5.1"
"svelte-preprocess": "^4.5.2"
}
}
1 change: 1 addition & 0 deletions packages/svelte-materialify/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
compiled
25 changes: 14 additions & 11 deletions packages/svelte-materialify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
"directory": "packages/svelte-materialify"
},
"author": "TheComputerM",
"main": "dist/index.js",
"module": "dist/index.mjs",
"main": "compiled/index.js",
"module": "compiled/index.mjs",
"svelte": "dist/index.js",
"scripts": {
"build": "concurrently \"yarn:build:js\" \"yarn:build:css\"",
"build:css": "sass src/styles/_global.scss:dist/global.css -I theme -s compressed --no-source-map",
"build": "concurrently \"yarn:build:js\" \"yarn:build:minimal\"",
"build:minimal": "node preprocess.js",
"build:js": "rollup -c",
"check": "svelte-check --workspace src/components",
"prepublishOnly": "concurrently \"yarn:build:js\" \"yarn:build:css\"",
"prepublishOnly": "concurrently \"yarn:build:js\" \"yarn:build:minimal\"",
"test": "jest",
"version": "standard-changelog && git add CHANGELOG.md"
},
"files": [
"@types",
"dist",
"compiled",
"src"
],
"keywords": [
Expand All @@ -40,7 +42,7 @@
"ui-kit"
],
"peerDependencies": {
"svelte": ">=3.28.0"
"svelte": ">=3.29.4"
},
"dependencies": {
"uid": "^1.0.0"
Expand All @@ -50,12 +52,13 @@
"@babel/preset-env": "^7.12.1",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/svelte": "^3.0.0",
"autoprefixer": "^10.0.1",
"babel-jest": "^26.6.0",
"babel-jest": "^26.6.1",
"concurrently": "^5.3.0",
"jest": "^26.6.0",
"del": "^6.0.0",
"glob": "^7.1.6",
"jest": "^26.6.1",
"postcss": "^8.1.3",
"rollup": "^2.32.1",
"rollup-plugin-bundle-size": "^1.0.3",
Expand All @@ -64,7 +67,7 @@
"sass": "^1.27.0",
"standard-changelog": "^2.0.24",
"svelte": "^3.29.4",
"svelte-check": "^1.0.61",
"svelte-check": "^1.1.1",
"svelte-htm": "^1.1.1",
"svelte-jester": "^1.1.5",
"svelte-preprocess": "^4.5.1"
Expand Down
41 changes: 41 additions & 0 deletions packages/svelte-materialify/preprocess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable no-console */
const { preprocess } = require('svelte/compiler');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const sveltePreprocess = require('svelte-preprocess');
const process = require('process');
const del = require('del');

const BASE = process.cwd();
const processor = sveltePreprocess({
scss: {
includePaths: [path.join(BASE, 'theme')],
},
});

del.sync(['dist/**']);
glob('src/**/*.svelte', {}, async (_, files) => {
// eslint-disable-next-line no-restricted-syntax
for await (const file of files) {
const source = fs.readFileSync(path.join(BASE, file), 'utf-8');
const filename = path.basename(file);
const dirname = path.dirname(file);
process.chdir(path.join(BASE, dirname));
const { code } = await preprocess(source, processor, { filename });
const outFolder = path.join(BASE, path.dirname(file.replace('src', 'dist')));
fs.mkdirSync(outFolder, { recursive: true });
fs.writeFileSync(path.join(outFolder, filename), code);
}
});

process.chdir(BASE);

glob('src/**/*.js', {}, (_, files) => {
files.forEach((file) => {
const outFolder = path.join(BASE, path.dirname(file.replace('src', 'dist')));
const filename = path.basename(file);
fs.mkdirSync(outFolder, { recursive: true });
fs.copyFileSync(path.join(BASE, file), path.join(outFolder, filename));
});
});
4 changes: 2 additions & 2 deletions packages/svelte-materialify/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const { preprocess } = require('./svelte.config');
export default {
input: 'src/index.js',
output: [
{ file: 'dist/index.mjs', sourcemap: true, format: 'es' },
{ file: 'dist/index.js', sourcemap: true, format: 'umd', name },
{ file: pkg.module, sourcemap: true, format: 'es' },
{ file: pkg.main, sourcemap: true, format: 'umd', name },
],
plugins: [
svelte({ preprocess }),
Expand Down
5 changes: 1 addition & 4 deletions packages/svelte-materialify/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ const sveltePreprocess = require('svelte-preprocess');
module.exports = {
preprocess: sveltePreprocess({
scss: {
includePaths: ['src', 'theme'],
},
postcss: {
plugins: [require('autoprefixer')],
includePaths: ['theme'],
},
}),
};

0 comments on commit 8669950

Please sign in to comment.