Skip to content

Commit c1ceefc

Browse files
committed
👌 Use webpack for build
1 parent 48da37b commit c1ceefc

File tree

5 files changed

+320
-224
lines changed

5 files changed

+320
-224
lines changed

‎.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
browser: true,
6+
},
7+
'extends': [
8+
'eslint:recommended'
9+
],
10+
parserOptions: {
11+
parser: 'babel-eslint'
12+
},
13+
rules: {
14+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
15+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
16+
}
17+
}

‎.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
singleQuote: true,
3+
semi: false,
4+
useTabs: true,
5+
tabWidth: 4
6+
};

‎Gruntfile.js

Lines changed: 138 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -1,217 +1,138 @@
1-
module.exports = function ( grunt ) {
2-
3-
require( 'load-grunt-tasks' )( grunt );
4-
5-
var conf = {
6-
plugin_branches: {
7-
include_files: [
8-
'assets/css/**',
9-
'assets/js/**',
10-
'assets/img/**',
11-
'includes/**',
12-
'admin/**',
13-
'public/**',
14-
'vendor/**',
15-
'disqus-conditional-load.php',
16-
'index.php',
17-
'LICENSE',
18-
'readme.txt',
19-
'uninstall.php'
20-
]
21-
},
22-
23-
plugin_dir: 'disqus-conditional-load/',
24-
plugin_file: 'disqus-conditional-load.php'
25-
};
26-
27-
// Project configuration.
28-
grunt.initConfig( {
29-
30-
pkg: grunt.file.readJSON( 'package.json' ),
31-
32-
// Make .pot file for translation.
33-
makepot: {
34-
options: {
35-
domainPath: 'languages',
36-
exclude: [
37-
'vendor/.*'
38-
],
39-
mainFile: 'disqus-conditional-load.php',
40-
potFilename: 'disqus-conditional-load.pot',
41-
potHeaders: {
42-
'poedit': true,
43-
'language-team': 'Joel James <me@joelsays.com>',
44-
'report-msgid-bugs-to': 'https://dclwp.com/',
45-
'last-translator': 'Joel James <me@joelsays.com>',
46-
'x-generator': 'grunt-wp-i18n'
47-
},
48-
type: 'wp-plugin',
49-
updateTimestamp: false, // Update POT-Creation-Date header if no other changes are detected.
50-
cwd: ''
51-
},
52-
// Make .pot file for the plugin.
53-
main: {
54-
options: {
55-
cwd: ''
56-
}
57-
},
58-
// Make .pot file for the release.
59-
release: {
60-
options: {
61-
cwd: 'releases/disqus-conditional-load'
62-
}
63-
}
64-
},
65-
66-
// Make .mo file from .pot file for translation.
67-
po2mo: {
68-
// Make .mo file for the plugin.
69-
main: {
70-
src: 'languages/disqus-conditional-load.pot',
71-
dest: 'languages/disqus-conditional-load.mo'
72-
},
73-
// Make .mo file for the release.
74-
release: {
75-
src: 'releases/disqus-conditional-load/languages/disqus-conditional-load.pot',
76-
dest: 'releases/disqus-conditional-load/languages/disqus-conditional-load.mo'
77-
}
78-
},
79-
80-
jshint: {
81-
files: [
82-
'assets/src/js/**/*.js'
83-
],
84-
options: {
85-
expr: true,
86-
globals: {
87-
jQuery: true,
88-
console: true,
89-
module: true,
90-
document: true
91-
}
92-
}
93-
},
94-
sass: {
95-
all: {
96-
options: {
97-
style: 'compressed',
98-
sourcemap: false
99-
},
100-
files: {
101-
'assets/css/admin/admin.min.css': 'assets/src/scss/admin/admin.scss'
102-
}
103-
}
104-
},
105-
uglify: {
106-
all: {
107-
options: {
108-
report: 'gzip'
109-
},
110-
files: {
111-
'assets/js/public/embed.min.js': 'assets/src/js/public/embed.js',
112-
'assets/js/public/embed-click.min.js': 'assets/src/js/public/embed-click.js',
113-
'assets/js/public/embed-count.min.js': 'assets/src/js/public/embed-count.js',
114-
'assets/js/public/embed-count-click.min.js': 'assets/src/js/public/embed-count-click.js',
115-
'assets/js/public/embed-count-scroll.min.js': 'assets/src/js/public/embed-count-scroll.js',
116-
'assets/js/public/embed-scroll.min.js': 'assets/src/js/public/embed-scroll.js'
117-
}
118-
}
119-
},
120-
121-
// Clean temp folders and release copies.
122-
clean: {
123-
temp: {
124-
src: [
125-
'**/*.tmp',
126-
'**/.afpDeleted*',
127-
'**/.DS_Store',
128-
],
129-
dot: true,
130-
filter: 'isFile'
131-
},
132-
folder_v2: [
133-
'releases/**',
134-
'assets/css/**',
135-
'assets/js/**'
136-
],
137-
},
138-
139-
// Verify in text domain is used properly.
140-
checktextdomain: {
141-
options: {
142-
text_domain: 'disqus-conditional-load',
143-
keywords: [
144-
'__:1,2d',
145-
'_e:1,2d',
146-
'_x:1,2c,3d',
147-
'esc_html__:1,2d',
148-
'esc_html_e:1,2d',
149-
'esc_html_x:1,2c,3d',
150-
'esc_attr__:1,2d',
151-
'esc_attr_e:1,2d',
152-
'esc_attr_x:1,2c,3d',
153-
'_ex:1,2c,3d',
154-
'_n:1,2,4d',
155-
'_nx:1,2,4c,5d',
156-
'_n_noop:1,2,3d',
157-
'_nx_noop:1,2,3c,4d'
158-
]
159-
},
160-
files: {
161-
src: [
162-
'admin/**/*.php',
163-
'includes/**/*.php',
164-
'public/**/*.php',
165-
'disqus-conditional-load.php'
166-
],
167-
expand: true
168-
}
169-
},
170-
171-
// Copy selected folder and files for release.
172-
copy: {
173-
files: {
174-
src: conf.plugin_branches.include_files,
175-
dest: 'releases/<%= pkg.name %>/'
176-
}
177-
},
178-
179-
// Compress release folder with version number.
180-
compress: {
181-
files: {
182-
options: {
183-
mode: 'zip',
184-
archive: './releases/<%= pkg.name %>-<%= pkg.version %>.zip'
185-
},
186-
expand: true,
187-
cwd: 'releases/<%= pkg.name %>/',
188-
src: ['**/*'],
189-
dest: conf.plugin_dir
190-
}
191-
}
192-
} );
193-
194-
// Check if text domain is used properly.
195-
grunt.registerTask( 'prepare', ['checktextdomain'] );
196-
197-
// Make pot file from files.
198-
grunt.registerTask( 'translate', ['makepot:main', 'po2mo:main'] );
199-
200-
// Compile and generate assets.
201-
grunt.registerTask( 'compile', [
202-
'jshint',
203-
'uglify',
204-
'sass'
205-
] );
206-
207-
// Run build task to create release copy.
208-
grunt.registerTask( 'build', 'Run all tasks.', function () {
209-
grunt.task.run( 'clean' );
210-
grunt.task.run( 'translate' );
211-
grunt.task.run( 'compile' );
212-
grunt.task.run( 'copy' );
213-
grunt.task.run( 'makepot:release' );
214-
grunt.task.run( 'po2mo:release' );
215-
grunt.task.run( 'compress' );
216-
} );
217-
};
1+
module.exports = function (grunt) {
2+
require('load-grunt-tasks')(grunt)
3+
4+
var conf = {
5+
plugin_branches: {
6+
include_files: [
7+
'assets/css/**',
8+
'assets/js/**',
9+
'assets/img/**',
10+
'includes/**',
11+
'admin/**',
12+
'public/**',
13+
'vendor/**',
14+
'disqus-conditional-load.php',
15+
'index.php',
16+
'LICENSE',
17+
'readme.txt',
18+
'uninstall.php',
19+
],
20+
},
21+
22+
plugin_dir: 'disqus-conditional-load/',
23+
plugin_file: 'disqus-conditional-load.php',
24+
}
25+
26+
// Project configuration.
27+
grunt.initConfig({
28+
pkg: grunt.file.readJSON('package.json'),
29+
30+
// Make .pot file for translation.
31+
makepot: {
32+
options: {
33+
domainPath: 'languages',
34+
exclude: ['vendor/.*'],
35+
mainFile: 'disqus-conditional-load.php',
36+
potFilename: 'disqus-conditional-load.pot',
37+
potHeaders: {
38+
poedit: true,
39+
'language-team': 'Joel James <me@joelsays.com>',
40+
'report-msgid-bugs-to': 'https://dclwp.com/',
41+
'last-translator': 'Joel James <me@joelsays.com>',
42+
'x-generator': 'grunt-wp-i18n',
43+
},
44+
type: 'wp-plugin',
45+
updateTimestamp: false, // Update POT-Creation-Date header if no other changes are detected.
46+
cwd: '',
47+
},
48+
// Make .pot file for the plugin.
49+
main: {
50+
options: {
51+
cwd: '',
52+
},
53+
},
54+
// Make .pot file for the release.
55+
release: {
56+
options: {
57+
cwd: 'releases/disqus-conditional-load',
58+
},
59+
},
60+
},
61+
62+
// Clean temp folders and release copies.
63+
clean: {
64+
main: ['releases/', '**/*.tmp', '**/.afpDeleted*', '**/.DS_Store'],
65+
assets: ['assets/css/**', 'assets/js/**'],
66+
},
67+
68+
// Verify in text domain is used properly.
69+
checktextdomain: {
70+
options: {
71+
text_domain: 'disqus-conditional-load',
72+
keywords: [
73+
'__:1,2d',
74+
'_e:1,2d',
75+
'_x:1,2c,3d',
76+
'esc_html__:1,2d',
77+
'esc_html_e:1,2d',
78+
'esc_html_x:1,2c,3d',
79+
'esc_attr__:1,2d',
80+
'esc_attr_e:1,2d',
81+
'esc_attr_x:1,2c,3d',
82+
'_ex:1,2c,3d',
83+
'_n:1,2,4d',
84+
'_nx:1,2,4c,5d',
85+
'_n_noop:1,2,3d',
86+
'_nx_noop:1,2,3c,4d',
87+
],
88+
},
89+
files: {
90+
src: [
91+
'admin/**/*.php',
92+
'includes/**/*.php',
93+
'public/**/*.php',
94+
'disqus-conditional-load.php',
95+
],
96+
expand: true,
97+
},
98+
},
99+
100+
// Copy selected folder and files for release.
101+
copy: {
102+
files: {
103+
src: conf.plugin_branches.include_files,
104+
dest: 'releases/<%= pkg.name %>/',
105+
},
106+
},
107+
108+
// Compress release folder with version number.
109+
compress: {
110+
files: {
111+
options: {
112+
mode: 'zip',
113+
archive:
114+
'./releases/<%= pkg.name %>-<%= pkg.version %>.zip',
115+
},
116+
expand: true,
117+
cwd: 'releases/<%= pkg.name %>/',
118+
src: ['**/*'],
119+
dest: conf.plugin_dir,
120+
},
121+
},
122+
})
123+
124+
// Check if text domain is used properly.
125+
grunt.registerTask('prepare', ['checktextdomain'])
126+
127+
// Make pot file from files.
128+
grunt.registerTask('translate', ['makepot:main'])
129+
130+
// Run build task to create release copy.
131+
grunt.registerTask('build', 'Run all tasks.', function () {
132+
grunt.task.run('clean:main')
133+
grunt.task.run('translate')
134+
grunt.task.run('copy')
135+
grunt.task.run('makepot:release')
136+
grunt.task.run('compress')
137+
})
138+
}

0 commit comments

Comments
 (0)