Skip to content

Commit 9673587

Browse files
authored
Merge pull request #5 from apalfrey/next
v0.2.0
2 parents f32ece9 + 727a297 commit 9673587

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4611
-906
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ vendor/
1010
# Misc
1111
*.log
1212

13-
# Compiled files
14-
assets/
13+
# Archives
1514
dist/
15+
*.zip
16+
*.tar
17+
*.gz
18+
*.tgz

.gulpconfig.js

Lines changed: 215 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
const pkg = require( './package.json' )
2+
const TerserPlugin = require( 'terser-webpack-plugin' )
23
const areas = {
34
constructWp: {
45
path: './plugins/construct-wp',
56
name: 'construct-wp',
67
title: 'ConstructWP',
7-
version: '0.1.0',
8+
version: '0.2.0',
9+
},
10+
}
11+
12+
const translatePipes = {
13+
checktextdomain: {
14+
text_domain: 'text-domain',
15+
keywords: [
16+
'__:1,2d',
17+
'_e:1,2d',
18+
'_x:1,2c,3d',
19+
'_ex:1,2c,3d',
20+
'_n:1,2,4d',
21+
'_nx:1,2,4c,5d',
22+
'_n_noop:1,2,3d',
23+
'_nx_noop:1,2,3c,4d',
24+
'esc_html__:1,2d',
25+
'esc_html_e:1,2d',
26+
'esc_html_x:1,2c,3d',
27+
'esc_attr__:1,2d',
28+
'esc_attr_e:1,2d',
29+
'esc_attr_x:1,2c,3d',
30+
],
31+
report_missing: true,
32+
report_success: false,
33+
report_variable_domain: true,
34+
correct_domain: true,
35+
create_report_file: false,
36+
force: false,
37+
},
38+
pot: {
39+
domain: 'text-domain',
40+
package: 'Package Name',
41+
team: `${pkg.author.name} <${pkg.author.email}>`,
42+
lastTranslator: `${pkg.author.name} <${pkg.author.email}>`,
843
},
944
}
1045

@@ -15,7 +50,6 @@ module.exports = {
1550
paths: [
1651
`${areas.constructWp.path}/assets`,
1752
`${areas.constructWp.path}/dist`,
18-
`${areas.constructWp.path}/languages`,
1953
],
2054
pipes: {
2155
del: {
@@ -43,7 +77,7 @@ module.exports = {
4377
src: {
4478
allowEmpty: true,
4579
base: `${areas.constructWp.path}/src/scss`,
46-
sourcemaps: process.env.NODE_ENV !== 'development',
80+
sourcemaps: process.env.NODE_ENV === 'development',
4781
},
4882
dest: {
4983
sourcemaps: '.',
@@ -103,6 +137,92 @@ module.exports = {
103137
},
104138
},
105139
},
140+
scripts: {
141+
process: true,
142+
watch: true,
143+
logColor: 'magenta',
144+
areas: [
145+
{
146+
paths: {
147+
src: `${areas.constructWp.path}/src/js/**/*`,
148+
watch: `${areas.constructWp.path}/src/js/**/*`,
149+
dest: `${areas.constructWp.path}/assets/js`,
150+
},
151+
minify: {
152+
process: process.env.NODE_ENV !== 'development',
153+
separate: false,
154+
},
155+
pipes: {
156+
// Put any pipe overrides here
157+
src: {
158+
allowEmpty: true,
159+
base: `${areas.constructWp.path}/src/js`,
160+
sourcemaps: process.env.NODE_ENV === 'development',
161+
},
162+
dest: {
163+
sourcemaps: '.',
164+
},
165+
},
166+
},
167+
],
168+
pipes: {
169+
filters: {
170+
lint: [
171+
'**/*.js',
172+
],
173+
build: [
174+
'**/*.js',
175+
'!**/libs/**/*.js',
176+
],
177+
},
178+
watch: {
179+
events: 'all',
180+
},
181+
eslint: {
182+
// Overrides the version of eslint used
183+
eslint: null,
184+
formatter: 'stylish',
185+
options: {
186+
fix: false,
187+
},
188+
},
189+
rollup: {
190+
// Overrides the version of rollup used.
191+
// Make sure to pass through the rollup function
192+
// e.g. require( 'rollup' ).rollup
193+
rollup: null,
194+
input: {
195+
plugins: [
196+
require( '@rollup/plugin-babel' ).babel( {
197+
exclude: 'node_modules/**',
198+
babelHelpers: 'bundled',
199+
} ),
200+
require( '@rollup/plugin-node-resolve' ).nodeResolve(),
201+
],
202+
treeshake: false,
203+
onwarn( e ) {
204+
if ( e.code === 'THIS_IS_UNDEFINED' ) {
205+
return
206+
}
207+
208+
console.warn( e.message )
209+
},
210+
},
211+
output: {
212+
file: 'scripts.js',
213+
name: 'Scripts',
214+
format: 'umd',
215+
generatedCode: 'es2015',
216+
globals: {},
217+
},
218+
},
219+
uglify: {
220+
output: {
221+
comments: '/^!|@preserve|@license|@cc_on/i',
222+
},
223+
},
224+
},
225+
},
106226
webpack: {
107227
process: true,
108228
watch: true,
@@ -123,7 +243,7 @@ module.exports = {
123243
src: {
124244
allowEmpty: true,
125245
base: `${areas.constructWp.path}/src/gutenberg`,
126-
sourcemaps: process.env.NODE_ENV !== 'development',
246+
sourcemaps: process.env.NODE_ENV === 'development',
127247
},
128248
dest: {
129249
sourcemaps: '.',
@@ -192,7 +312,9 @@ module.exports = {
192312
},
193313
],
194314
],
195-
plugins: [],
315+
plugins: [
316+
'@automattic/babel-plugin-preserve-i18n',
317+
],
196318
},
197319
},
198320
},
@@ -201,8 +323,42 @@ module.exports = {
201323
resolve: {
202324
extensions: ['.js', '.jsx', '.json'],
203325
},
204-
devtool: process.env.NODE_ENV == 'development' ? 'source-map' : false,
205-
mode: process.env.NODE_ENV == 'development' ? 'development' : 'production',
326+
optimization: {
327+
minimizer: [
328+
new TerserPlugin( {
329+
parallel: true,
330+
terserOptions: {
331+
output: {
332+
comments: /translators:/i,
333+
},
334+
compress: {
335+
passes: 2,
336+
},
337+
mangle: {
338+
reserved: [
339+
'__',
340+
'_e',
341+
'_x',
342+
'_ex',
343+
'_n',
344+
'_nx',
345+
'_n_noop',
346+
'_nx_noop',
347+
'esc_html__',
348+
'esc_html_e',
349+
'esc_html_x',
350+
'esc_attr__',
351+
'esc_attr_e',
352+
'esc_attr_x',
353+
],
354+
},
355+
},
356+
extractComments: false,
357+
} ),
358+
],
359+
},
360+
devtool: process.env.NODE_ENV === 'development' ? 'source-map' : false,
361+
mode: process.env.NODE_ENV === 'development' ? 'development' : 'production',
206362
},
207363
},
208364
uglify: {
@@ -229,43 +385,59 @@ module.exports = {
229385
allowEmpty: true,
230386
},
231387
dest: {},
388+
checktextdomain: {
389+
...translatePipes.checktextdomain,
390+
text_domain: areas.constructWp.name,
391+
},
392+
pot: {
393+
...translatePipes.pot,
394+
domain: areas.constructWp.name,
395+
package: areas.constructWp.title,
396+
relativeTo: areas.constructWp.path,
397+
},
232398
},
233399
},
234-
],
235-
pipes: {
236-
checktextdomain: {
237-
text_domain: areas.constructWp.name,
238-
keywords: [
239-
'__:1,2d',
240-
'_e:1,2d',
241-
'_x:1,2c,3d',
242-
'_ex:1,2c,3d',
243-
'_n:1,2,4d',
244-
'_nx:1,2,4c,5d',
245-
'_n_noop:1,2,3d',
246-
'_nx_noop:1,2,3c,4d',
247-
'esc_html__:1,2d',
248-
'esc_html_e:1,2d',
249-
'esc_html_x:1,2c,3d',
250-
'esc_attr__:1,2d',
251-
'esc_attr_e:1,2d',
252-
'esc_attr_x:1,2c,3d',
253-
],
254-
report_missing: true,
255-
report_success: false,
256-
report_variable_domain: true,
257-
correct_domain: true,
258-
create_report_file: false,
259-
force: false,
260-
},
261-
pot: {
262-
domain: areas.constructWp.name,
263-
package: areas.constructWp.title,
264-
lastTranslator: `${pkg.author.name} <${pkg.author.email}>`,
265-
headers: {
266-
'Language-Team': `${pkg.author.name} <${pkg.author.email}>`,
400+
{
401+
paths: {
402+
src: `${areas.constructWp.path}/assets/js/**/*.js`,
403+
watch: `${areas.constructWp.path}/assets/js/**/*.js`,
404+
dest: `${areas.constructWp.path}/languages/js/${areas.constructWp.name}.pot`,
405+
},
406+
pipes: {
407+
// Put any pipe overrides here
408+
src: {
409+
allowEmpty: true,
410+
},
411+
dest: {},
412+
checktextdomain: {
413+
...translatePipes.checktextdomain,
414+
text_domain: areas.constructWp.name,
415+
},
416+
pot: {
417+
...translatePipes.pot,
418+
domain: areas.constructWp.name,
419+
package: areas.constructWp.title,
420+
relativeTo: areas.constructWp.path,
421+
parser: 'js',
422+
parserOptions: {
423+
ecmaVersion: 9,
424+
},
425+
},
267426
},
268427
},
428+
],
429+
pipes: translatePipes,
430+
},
431+
po2json: {
432+
process: true,
433+
watch: true,
434+
paths: [
435+
`${areas.constructWp.path}/languages/**/*.po`,
436+
],
437+
bin: 'vendor/bin/wp',
438+
pretty: true,
439+
execSync: {
440+
shell: 'C:\\Program Files\\Git\\bin\\bash.exe',
269441
},
270442
},
271443
browsersync: {
@@ -275,8 +447,9 @@ module.exports = {
275447
port: 4000,
276448
ui: false,
277449
files: [
278-
'**/*',
279-
'!**/src/**/*'
450+
'plugins/**/*',
451+
'themes/**/*',
452+
'!**/src/**/*',
280453
],
281454
ghostmode: false,
282455
open: false,

.vscode/bookmarks.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"files": [
3+
{
4+
"path": ".gulpconfig.js",
5+
"bookmarks": [
6+
{
7+
"line": 7,
8+
"column": 18,
9+
"label": "Version number"
10+
}
11+
]
12+
},
13+
{
14+
"path": "plugins/construct-wp/construct-wp.php",
15+
"bookmarks": [
16+
{
17+
"line": 5,
18+
"column": 22,
19+
"label": "Version number"
20+
},
21+
{
22+
"line": 34,
23+
"column": 24,
24+
"label": "Version number"
25+
}
26+
]
27+
},
28+
{
29+
"path": "plugins/construct-wp/README.txt",
30+
"bookmarks": [
31+
{
32+
"line": 6,
33+
"column": 12,
34+
"label": "Version number"
35+
},
36+
{
37+
"line": 49,
38+
"column": 0,
39+
"label": "Changelog"
40+
}
41+
]
42+
},
43+
{
44+
"path": "README.md",
45+
"bookmarks": [
46+
{
47+
"line": 37,
48+
"column": 0,
49+
"label": "Changelog"
50+
}
51+
]
52+
}
53+
]
54+
}

0 commit comments

Comments
 (0)