|
| 1 | +const pkg = require( './package.json' ) |
| 2 | +const areas = { |
| 3 | + constructWp: { |
| 4 | + path: './plugins/construct-wp', |
| 5 | + name: 'construct-wp', |
| 6 | + title: 'ConstructWP', |
| 7 | + version: '0.1.0', |
| 8 | + }, |
| 9 | +} |
| 10 | + |
| 11 | +module.exports = { |
| 12 | + clean: { |
| 13 | + process: true, |
| 14 | + logColor: 'red', |
| 15 | + paths: [ |
| 16 | + `${areas.constructWp.path}/assets`, |
| 17 | + `${areas.constructWp.path}/dist`, |
| 18 | + `${areas.constructWp.path}/languages`, |
| 19 | + ], |
| 20 | + pipes: { |
| 21 | + del: { |
| 22 | + force: true, |
| 23 | + }, |
| 24 | + }, |
| 25 | + }, |
| 26 | + styles: { |
| 27 | + process: true, |
| 28 | + watch: true, |
| 29 | + logColor: 'yellow', |
| 30 | + areas: [ |
| 31 | + { |
| 32 | + paths: { |
| 33 | + src: `${areas.constructWp.path}/src/scss/**/*`, |
| 34 | + watch: `${areas.constructWp.path}/src/scss/**/*`, |
| 35 | + dest: `${areas.constructWp.path}/assets/css`, |
| 36 | + }, |
| 37 | + minify: { |
| 38 | + process: process.env.NODE_ENV !== 'development', |
| 39 | + separate: false, |
| 40 | + }, |
| 41 | + pipes: { |
| 42 | + // Put any pipe overrides here |
| 43 | + src: { |
| 44 | + allowEmpty: true, |
| 45 | + base: `${areas.constructWp.path}/src/scss`, |
| 46 | + sourcemaps: process.env.NODE_ENV !== 'development', |
| 47 | + }, |
| 48 | + dest: { |
| 49 | + sourcemaps: '.', |
| 50 | + }, |
| 51 | + }, |
| 52 | + }, |
| 53 | + ], |
| 54 | + pipes: { |
| 55 | + filters: { |
| 56 | + lint: [ |
| 57 | + '**/*.scss', |
| 58 | + ], |
| 59 | + build: [ |
| 60 | + '**/*.scss', |
| 61 | + '!**/_*.scss', |
| 62 | + ], |
| 63 | + }, |
| 64 | + watch: { |
| 65 | + events: 'all', |
| 66 | + }, |
| 67 | + stylelint: { |
| 68 | + // Overrides the version of stylelint used |
| 69 | + stylelint: null, |
| 70 | + options: { |
| 71 | + formatter: 'verbose', |
| 72 | + }, |
| 73 | + }, |
| 74 | + sass: { |
| 75 | + // Overrides the version of sass used |
| 76 | + sass: null, |
| 77 | + sync: true, |
| 78 | + options: { |
| 79 | + style: 'expanded', |
| 80 | + loadPaths: [ |
| 81 | + '.' |
| 82 | + ], |
| 83 | + }, |
| 84 | + }, |
| 85 | + postcss() { |
| 86 | + return { |
| 87 | + plugins: [ |
| 88 | + require( 'autoprefixer' )( { |
| 89 | + cascade: false, |
| 90 | + } ), |
| 91 | + ], |
| 92 | + options: {}, |
| 93 | + } |
| 94 | + }, |
| 95 | + cssnano: { |
| 96 | + preset: [ |
| 97 | + 'default', |
| 98 | + { |
| 99 | + cssDeclarationSorter: false, |
| 100 | + svgo: false, |
| 101 | + }, |
| 102 | + ], |
| 103 | + }, |
| 104 | + }, |
| 105 | + }, |
| 106 | + webpack: { |
| 107 | + process: true, |
| 108 | + watch: true, |
| 109 | + logColor: 'magenta', |
| 110 | + areas: [ |
| 111 | + { |
| 112 | + paths: { |
| 113 | + src: `${areas.constructWp.path}/src/gutenberg/*`, |
| 114 | + watch: `${areas.constructWp.path}/src/gutenberg/**/*`, |
| 115 | + dest: `${areas.constructWp.path}/assets/js`, |
| 116 | + }, |
| 117 | + minify: { |
| 118 | + process: process.env.NODE_ENV !== 'development', |
| 119 | + separate: false, |
| 120 | + }, |
| 121 | + pipes: { |
| 122 | + // Put any pipe overrides here |
| 123 | + src: { |
| 124 | + allowEmpty: true, |
| 125 | + base: `${areas.constructWp.path}/src/gutenberg`, |
| 126 | + sourcemaps: process.env.NODE_ENV !== 'development', |
| 127 | + }, |
| 128 | + dest: { |
| 129 | + sourcemaps: '.', |
| 130 | + }, |
| 131 | + }, |
| 132 | + }, |
| 133 | + ], |
| 134 | + pipes: { |
| 135 | + filters: { |
| 136 | + lint: [ |
| 137 | + '**/*.js', |
| 138 | + '**/*.jsx', |
| 139 | + ], |
| 140 | + build: [ |
| 141 | + '**/*.js', |
| 142 | + '**/*.jsx', |
| 143 | + '!**/libs/**/*', |
| 144 | + ], |
| 145 | + }, |
| 146 | + watch: { |
| 147 | + events: 'all', |
| 148 | + }, |
| 149 | + eslint: { |
| 150 | + // Overrides the version of eslint used |
| 151 | + eslint: null, |
| 152 | + formatter: 'stylish', |
| 153 | + options: { |
| 154 | + fix: false, |
| 155 | + }, |
| 156 | + }, |
| 157 | + webpack: { |
| 158 | + // Overrides the version of webpack used. |
| 159 | + webpack: null, |
| 160 | + options: { |
| 161 | + externals: { |
| 162 | + wp: 'wp', |
| 163 | + '@wordpress': 'wp', |
| 164 | + '@wordpress/blocks': 'wp.blocks', |
| 165 | + '@wordpress/block-editor': 'wp.blockEditor', |
| 166 | + '@wordpress/components': 'wp.components', |
| 167 | + '@wordpress/data': 'wp.data', |
| 168 | + '@wordpress/edit-post': 'wp.editPost', |
| 169 | + '@wordpress/element': 'wp.element', |
| 170 | + '@wordpress/hooks': 'wp.hooks', |
| 171 | + '@wordpress/i18n': 'wp.i18n', |
| 172 | + '@wordpress/notices': 'wp.notices', |
| 173 | + '@wordpress/plugins': 'wp.plugins', |
| 174 | + react: 'React', |
| 175 | + 'react-dom': 'ReactDOM', |
| 176 | + }, |
| 177 | + target: 'browserslist', |
| 178 | + module: { |
| 179 | + rules: [ |
| 180 | + { |
| 181 | + test: /\.jsx?$/, |
| 182 | + exclude: /(node_modules|bower_components)/, |
| 183 | + use: { |
| 184 | + loader: 'babel-loader', |
| 185 | + options: { |
| 186 | + presets: [ |
| 187 | + '@babel/preset-env', |
| 188 | + [ |
| 189 | + '@babel/preset-react', |
| 190 | + { |
| 191 | + pragma: 'wp.element.createElement', |
| 192 | + }, |
| 193 | + ], |
| 194 | + ], |
| 195 | + plugins: [], |
| 196 | + }, |
| 197 | + }, |
| 198 | + }, |
| 199 | + ], |
| 200 | + }, |
| 201 | + resolve: { |
| 202 | + extensions: ['.js', '.jsx', '.json'], |
| 203 | + }, |
| 204 | + devtool: process.env.NODE_ENV == 'development' ? 'source-map' : false, |
| 205 | + mode: process.env.NODE_ENV == 'development' ? 'development' : 'production', |
| 206 | + }, |
| 207 | + }, |
| 208 | + uglify: { |
| 209 | + output: { |
| 210 | + comments: '/^!|@preserve|@license|@cc_on/i', |
| 211 | + }, |
| 212 | + }, |
| 213 | + }, |
| 214 | + }, |
| 215 | + translate: { |
| 216 | + process: true, |
| 217 | + watch: true, |
| 218 | + logColor: 'black', |
| 219 | + areas: [ |
| 220 | + { |
| 221 | + paths: { |
| 222 | + src: `${areas.constructWp.path}/**/*.php`, |
| 223 | + watch: `${areas.constructWp.path}/**/*.php`, |
| 224 | + dest: `${areas.constructWp.path}/languages/${areas.constructWp.name}.pot`, |
| 225 | + }, |
| 226 | + pipes: { |
| 227 | + // Put any pipe overrides here |
| 228 | + src: { |
| 229 | + allowEmpty: true, |
| 230 | + }, |
| 231 | + dest: {}, |
| 232 | + }, |
| 233 | + }, |
| 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}>`, |
| 267 | + }, |
| 268 | + }, |
| 269 | + }, |
| 270 | + }, |
| 271 | + browsersync: { |
| 272 | + watch: true, |
| 273 | + browsersync: { |
| 274 | + proxy: 'localhost:8000', |
| 275 | + port: 4000, |
| 276 | + ui: false, |
| 277 | + files: [ |
| 278 | + '**/*', |
| 279 | + '!**/src/**/*' |
| 280 | + ], |
| 281 | + ghostmode: false, |
| 282 | + open: false, |
| 283 | + notify: true, |
| 284 | + watch: true, |
| 285 | + }, |
| 286 | + }, |
| 287 | + archive: { |
| 288 | + process: true, |
| 289 | + areas: [ |
| 290 | + { |
| 291 | + paths: { |
| 292 | + src: [ |
| 293 | + `${areas.constructWp.path}/**/*`, |
| 294 | + `!${areas.constructWp.path}/dist/**`, |
| 295 | + `!${areas.constructWp.path}/src/**`, |
| 296 | + `!${areas.constructWp.path}/**/*.zip*`, |
| 297 | + `!${areas.constructWp.path}/**/*.tar`, |
| 298 | + ], |
| 299 | + dest: `${areas.constructWp.path}/dist`, |
| 300 | + }, |
| 301 | + pipes: { |
| 302 | + src: { |
| 303 | + allowEmpty: true, |
| 304 | + base: './plugins', |
| 305 | + }, |
| 306 | + dest: {}, |
| 307 | + archiver: { |
| 308 | + filename: `${areas.constructWp.name}-${areas.constructWp.version}.zip`, |
| 309 | + format: 'zip', |
| 310 | + options: { |
| 311 | + gzip: false, |
| 312 | + }, |
| 313 | + }, |
| 314 | + }, |
| 315 | + }, |
| 316 | + ], |
| 317 | + }, |
| 318 | +} |
0 commit comments