Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow overriding certain config files #355

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading