-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow overriding certain config files (#355)
- Loading branch information
1 parent
e10cf6f
commit 01ade56
Showing
22 changed files
with
792 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"10up-toolkit": patch | ||
--- | ||
|
||
Fix: allow overriding buildfiles.config.js, filenames.config.js and paths.config.js as stated in README |
1 change: 1 addition & 0 deletions
1
packages/toolkit/__tests__/build-project-overriding-config-files/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./dist |
1 change: 1 addition & 0 deletions
1
.../__tests__/build-project-overriding-config-files/__fixtures__/assets/css/admin-styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.admin-class { color: blue; } |
1 change: 1 addition & 0 deletions
1
...lkit/__tests__/build-project-overriding-config-files/__fixtures__/assets/css/frontend.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.test { color: red; } |
3 changes: 3 additions & 0 deletions
3
...s/toolkit/__tests__/build-project-overriding-config-files/__fixtures__/assets/js/admin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../css/admin-styles.css'; | ||
|
||
export const admin = () => {}; |
13 changes: 13 additions & 0 deletions
13
...oolkit/__tests__/build-project-overriding-config-files/__fixtures__/assets/js/frontend.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* eslint-disable*/ | ||
import * as React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { useState } from 'react'; | ||
|
||
const App = () => { | ||
const [state] = useState(1); | ||
|
||
return <p>This is a react app {state}</p>; | ||
}; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
|
43 changes: 43 additions & 0 deletions
43
...s__/build-project-overriding-config-files/__fixtures__/includes/blocks/example/block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"title": "Example Block", | ||
"description": "An Example Block", | ||
"textdomain": "tenup-scaffold", | ||
"name": "tenup/example", | ||
"icon": "feedback", | ||
"category": "tenup-scaffold-blocks", | ||
"attributes": { | ||
"title": { | ||
"type": "string" | ||
} | ||
}, | ||
"example": { | ||
"attributes": { | ||
"title": "Example Block" | ||
} | ||
}, | ||
"supports": { | ||
"align": false, | ||
"alignWide": false, | ||
"anchor": false, | ||
"color": { | ||
"gradients": false, | ||
"background": false, | ||
"text": false | ||
}, | ||
"customClassName": false, | ||
"defaultStylePicker": false, | ||
"typography": { | ||
"fontSize": false, | ||
"lineHeight": true | ||
}, | ||
"html": false, | ||
"inserter": true, | ||
"multiple": true, | ||
"reusable": false, | ||
"spacing": { | ||
"padding": false | ||
} | ||
}, | ||
"editorScript": "file:../../../../dist/editor.js", | ||
"editorStyle": "file:../../../../dist/editor.css" | ||
} |
4 changes: 4 additions & 0 deletions
4
...ests__/build-project-overriding-config-files/__fixtures__/includes/blocks/example/edit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import './editor-styles.css'; | ||
|
||
const ExampleBlockEdit = () => {}; | ||
export default ExampleBlockEdit; |
1 change: 1 addition & 0 deletions
1
...ld-project-overriding-config-files/__fixtures__/includes/blocks/example/editor-styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Editor specific styles */ |
11 changes: 11 additions & 0 deletions
11
...sts__/build-project-overriding-config-files/__fixtures__/includes/blocks/example/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable */ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
import edit from './edit'; | ||
import save from './save'; | ||
import block from './block.json'; | ||
|
||
registerBlockType(block, { | ||
edit, | ||
save, | ||
}); |
8 changes: 8 additions & 0 deletions
8
...ests__/build-project-overriding-config-files/__fixtures__/includes/blocks/example/save.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save | ||
* | ||
* @returns {null} Dynamic blocks do not save the HTML. | ||
*/ | ||
const ExampleBlockSave = () => null; | ||
|
||
export default ExampleBlockSave; |
9 changes: 9 additions & 0 deletions
9
packages/toolkit/__tests__/build-project-overriding-config-files/filenames.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// filenames.config.js | ||
module.exports = { | ||
js: 'js/test/[name].js', | ||
jsChunk: 'js/test/[name].[contenthash].chunk.js', | ||
css: 'css/test/[name].css', | ||
// changing where gutenberg blocks assets are stored. | ||
block: 'js/test/blocks/[name]/editor.js', | ||
blockCSS: 'css/test/blocks/[name]/editor.css', | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/toolkit/__tests__/build-project-overriding-config-files/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "test-build-project", | ||
"10up-toolkit": { | ||
"useBlockAssets": false, | ||
"entry": { | ||
"admin": "./__fixtures__/assets/js/admin.js", | ||
"frontend": "./__fixtures__/assets/js/frontend.js", | ||
"frontend-css": "./__fixtures__/assets/css/frontend.css", | ||
"example-block": "./__fixtures__/includes/blocks/example/index.js" | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/toolkit/__tests__/build-project-overriding-config-files/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import spawn from 'cross-spawn'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
describe('build a project (overriding config)', () => { | ||
it('builds and compiles js and css', async () => { | ||
spawn.sync('node', ['../../scripts/build'], { | ||
cwd: __dirname, | ||
}); | ||
|
||
expect(fs.existsSync(path.join(__dirname, 'dist', 'js', 'test', 'admin.js'))).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'js', 'test', 'admin.asset.php')), | ||
).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'js', 'test', 'frontend.js')), | ||
).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'js', 'test', 'frontend.asset.php')), | ||
).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'css', 'test', 'frontend-css.css')), | ||
).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'css', 'test', 'frontend-css.asset.php')), | ||
).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.