Skip to content

Commit

Permalink
allow overriding certain config files (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio authored Jan 9, 2024
1 parent e10cf6f commit 01ade56
Show file tree
Hide file tree
Showing 22 changed files with 792 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-ties-hang.md
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.admin-class { color: blue; }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.test { color: red; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '../css/admin-styles.css';

export const admin = () => {};
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'));

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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import './editor-styles.css';

const ExampleBlockEdit = () => {};
export default ExampleBlockEdit;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Editor specific styles */
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,
});
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;
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',
};
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"
}
}
}
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();
});
});
Loading

0 comments on commit 01ade56

Please sign in to comment.