Skip to content

Commit

Permalink
feat: improve build process
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh95 committed Oct 14, 2022
1 parent 6c7e9ce commit 2ba3ea5
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 16 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "0.3.1-alpha.0",
"version": "0.0.1",
"private": true,
"license": "MIT",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig(({ mode }) => {
{},
);

// Inject NODE_ENV and make sure envWithProcessPrefix is not empty
// @ts-expect-error Inject NODE_ENV and make sure envWithProcessPrefix is not empty
envWithProcessPrefix['process.env.NODE_ENV'] = `'${mode}'`;

return {
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@
"ws": "^8.5.0"
},
"devDependencies": {
"@types/jest": "27",
"@jest/types": "27",
"@babel/core": "^7.18.10",
"@jest/types": "27",
"@rollup/plugin-node-resolve": "^15.0.0",
"@types/connect": "^3.4.35",
"@types/jest": "27",
"@types/node": "^18.6.3",
"@types/react": "^17.0.48",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
Expand All @@ -96,9 +98,9 @@
"npm-run-all": "^4.1.5",
"prettier": "^2.6.0",
"react-is": "^18.2.0",
"rollup": "^2.77.2",
"rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-typescript2": "^0.34.1",
"typescript": "^4.6.3"
},
"bug": {
Expand Down
87 changes: 82 additions & 5 deletions pnpm-lock.yaml

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

16 changes: 13 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { defineConfig } from 'rollup';
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';

import packageJson from './package.json';
function makeBundle({ filePath, dir = 'dist' }) {
return {
input: filePath,
output: {
dir: dir,
dir,
format: 'cjs',
},
plugins: [typescript()],
external: ['path', 'camelcase', 'fs', 'child_process'],
plugins: [
typescript({
tsconfig: 'tsconfig.prod.json',
}),
resolve(),
],
external: [
...Object.keys(packageJson.dependencies),
...Object.keys(packageJson.devDependencies),
],
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/less/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { processLess } from '../../transform';
import less from 'less';

describe('Less', () => {
it('should compile LESS successfully', () => {
const result = processLess(path.resolve(__dirname, './style.less'));
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig",
"exclude": ["./demo/__tests__/**", "./demo/__mocks__/**", "./demo/test-utils"]
"exclude": ["./demo", "./src/__tests__/**"]
}

0 comments on commit 2ba3ea5

Please sign in to comment.