Skip to content

Commit

Permalink
chore(build): improve build process (#461)
Browse files Browse the repository at this point in the history
* chore(build): improve build process

* remove comment
  • Loading branch information
christian-bromann authored Jan 23, 2024
1 parent 6774845 commit 21e7a77
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
51 changes: 44 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"prettier": "npm run prettier.base -- --write",
"prettier.base": "prettier --cache 'src/**/*.ts'",
"prettier.dry-run": "npm run prettier.base -- --list-different",
"build": "npm run prebuild && tsc && npm run rollup",
"watch": "tsc --watch",
"build": "npm run prebuild && npm run rollup",
"watch": "npm run rollup -- --watch",
"rollup": "rollup -c rollup.config.mjs",
"version": "npm run build",
"release": "np",
Expand All @@ -32,6 +32,7 @@
"devDependencies": {
"@ionic/prettier-config": "^4.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^11.1.6",
"@stencil/core": "^4.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^20.2.0",
Expand Down
11 changes: 5 additions & 6 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { createRequire } from 'node:module';
import fs from 'node:fs/promises'
import pluginSass from './rollup.plugin.sass.mjs';
import typescript from '@rollup/plugin-typescript';
import rollupResolve from '@rollup/plugin-node-resolve';

// require `package.json` in order to use its 'main' and 'module' fields to tell rollup where to output the generated
// bundles
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const pkg = JSON.parse((await fs.readFile('./package.json')));

/**
* Generate an ESM and a CJS output bundle
*/
export default {
// the input is expected to exist at this location as a result of running the typescript compiler
input: 'dist/index.js',
input: 'src/index.ts',

plugins: [
typescript(),
pluginSass(),
rollupResolve({
preferBuiltins: true
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type LegacyException, type LegacyResult, render } from 'sass';

import * as d from './declarations';
import { loadDiagnostic } from './diagnostics';
import { createResultsId, getRenderOptions, usePlugin } from './util';
Expand Down
7 changes: 4 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import path from 'node:path';
import type { LegacyAsyncImporter, LegacyImporterResult } from 'sass';
import type { LegacyOptions } from 'sass/types/legacy/options';

import * as d from './declarations';
import * as path from 'path';
import { LegacyAsyncImporter, LegacyImporterResult } from 'sass';
import { LegacyOptions } from 'sass/types/legacy/options';

/**
* Determine if the Sass plugin should be applied, based on the provided `fileName`
Expand Down

0 comments on commit 21e7a77

Please sign in to comment.