Skip to content

Commit 023bb8a

Browse files
committed
Add config variables for dev host, path, and output path
1 parent d17b49f commit 023bb8a

5 files changed

Lines changed: 1343 additions & 1330 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ Add a `gutenblock.config.js` file in your blocks folder. It looks like this:
8787
const path = require('path');
8888

8989
module.exports = webpack => ({
90+
//customize gutenblock options if needed
91+
gutenblock: {
92+
devHost: 'localhost',
93+
devPort: 8080,
94+
//build asset output path relative to the plugin directory
95+
outputPath: '/test',
96+
//when building the plugin, gutenblock will default to the folder name inside wp-content, if you have a different wp-content folder you can change it here
97+
publicPath: `/app/plugins/blocks/test/`,
98+
},
9099
resolve: {
91100
alias: {
92101
shared: path.resolve(__dirname, '../src/shared'),

cli/build/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ module.exports = () => {
1717
console.log('Building...');
1818

1919
webpack(customConfig, (err, stats) => {
20-
if (err || stats.hasErrors()) {
21-
console.error(err);
22-
}
20+
if (err) console.error(err);
21+
2322
console.log('Done!');
2423
});
2524
};

config/base.webpack.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ module.exports = ({
2020
delete customConfig.babelOptions;
2121
}
2222

23+
let gutenblock = customConfig.gutenblock;
24+
delete customConfig.gutenblock;
25+
port = gutenblock.devPort || port;
26+
2327
//merge custom rules
2428
let module = {
2529
rules: [
@@ -63,14 +67,15 @@ module.exports = ({
6367
output: {
6468
chunkFilename: '[name].chunk.js',
6569
filename: '[name].js',
66-
path: process.cwd() + '/build',
70+
path: process.cwd() + (gutenblock.outputPath || '/build'),
6771
publicPath: production
68-
? `/wp-content/plugins/${pluginFolderName}/build/`
72+
? gutenblock.publicPath ||
73+
`/wp-content/plugins/${pluginFolderName}/build/`
6974
: `http://localhost:${port}/`,
7075
},
7176
serve: {
7277
port,
73-
host: '0.0.0.0',
78+
host: gutenblock.devHost || '0.0.0.0',
7479
add: (app, middleware) => {
7580
app.use((ctx, next) => {
7681
ctx.set('Access-Control-Allow-Origin', '*');

0 commit comments

Comments
 (0)