Skip to content

Commit

Permalink
fix(configuration): add copy plugin only to first user configuration
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Nov 14, 2023
1 parent e523736 commit b7df4a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ npm init now papua ./my-project
npm init now papua . javascript
```

Replace `npm init` with `bun create` if you're already living in the future 🚀

The following [templates](https://github.com/tobua/papua/tree/main/template) are available:

- default (TS + React)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@babel/preset-react": "^7.23.3",
"@manypkg/find-root": "^2.2.1",
"@npmcli/map-workspaces": "^3.0.4",
"@rspack/core": "^0.3.11",
"@rspack/dev-server": "^0.3.11",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@rspack/core": "^0.3.12",
"@rspack/dev-server": "^0.3.12",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"ajv": "^8.12.0",
"chalk": "^5.3.0",
"commander": "^11.1.0",
Expand Down Expand Up @@ -72,7 +72,7 @@
"parse-gitignore": "^2.0.0",
"postcss-styled": "^0.34.0",
"postcss-syntax": "^0.36.2",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"pretty-bytes": "^6.1.1",
"pretty-ms": "^8.0.0",
"prompts": "^2.4.2",
Expand Down
9 changes: 9 additions & 0 deletions test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ test('Builds without errors.', async () => {
test('Works with TypeScript.', async () => {
const { dist } = prepare([packageJson('build-ts'), file('index.ts', `console.log('test')`)])

writeFile(
'node_modules/papua/configuration/.prettierignore',
readFile('../../../configuration/.prettierignore'),
)
writeFile(
'node_modules/papua/configuration/template.html',
readFile('../../../configuration/template.html'),
)

await configure() // Required for tsconfig.json
await build(false)

Expand Down
3 changes: 2 additions & 1 deletion utility/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const createSingleRspackConfiguration = (
// Usage of legacy builtins by user will lead to warning.
plugins: [
!userConfiguration.builtins?.define && baseConfiguration.plugins[0],
!userConfiguration.builtins?.copy && baseConfiguration.plugins[1],
// Copy and Html plugin will only be added automatically to first configuration.
!userConfiguration.builtins?.copy && index === 0 && baseConfiguration.plugins[1],
!userConfiguration.builtins?.html && index === 0 && baseConfiguration.plugins[2],
...baseConfiguration.plugins.slice(3),
].filter(Boolean),
Expand Down

0 comments on commit b7df4a0

Please sign in to comment.