@caweb/webpack 1.2.28 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/config-publish.yml +33 -0
- package/.github/workflows/plugins-publish.yml +45 -0
- package/.github/workflows/test +29 -0
- package/.gitmodules +3 -0
- package/README.md +1 -2
- package/changelog.txt +140 -0
- package/package.json +9 -16
- package/plugins/a11y/README.md +19 -0
- package/plugins/a11y/aceconfig.js +44 -0
- package/plugins/a11y/changelog.txt +31 -0
- package/plugins/a11y/index.js +271 -0
- package/plugins/a11y/package-lock.json +3303 -0
- package/plugins/a11y/package.json +42 -0
- package/plugins/css-audit/README.md +20 -0
- package/plugins/css-audit/changelog.txt +41 -0
- package/plugins/css-audit/css-audit.config.cjs +5 -0
- package/plugins/css-audit/default.config.js +19 -0
- package/plugins/css-audit/index.js +326 -0
- package/plugins/css-audit/package-lock.json +1522 -0
- package/plugins/css-audit/package.json +53 -0
- package/plugins/css-audit/sample/no-files.html +9 -0
- package/plugins/html/README.md +40 -0
- package/plugins/html/changelog.txt +139 -0
- package/plugins/html/entry/delta.js +20 -0
- package/plugins/html/entry/eureka.js +20 -0
- package/plugins/html/entry/mono.js +20 -0
- package/plugins/html/entry/oceanside.js +20 -0
- package/plugins/html/entry/orangecounty.js +20 -0
- package/plugins/html/entry/pasorobles.js +20 -0
- package/plugins/html/entry/sacramento.js +20 -0
- package/plugins/html/entry/santabarbara.js +20 -0
- package/plugins/html/entry/santacruz.js +20 -0
- package/plugins/html/entry/shasta.js +20 -0
- package/plugins/html/entry/sierra.js +20 -0
- package/plugins/html/entry/trinity.js +20 -0
- package/plugins/html/index.js +96 -0
- package/plugins/html/package-lock.json +21977 -0
- package/plugins/html/package.json +71 -0
- package/plugins/html/sample/blank.html +13 -0
- package/plugins/html/sample/components/alerts.html +32 -0
- package/plugins/html/sample/components/animations.html +7 -0
- package/plugins/html/sample/components/buttons.html +5 -0
- package/plugins/html/sample/components/cards.html +73 -0
- package/plugins/html/sample/components/lists.html +75 -0
- package/plugins/html/sample/components/locations.html +49 -0
- package/plugins/html/sample/components/profile-banners.html +48 -0
- package/plugins/html/sample/components/sections.html +16 -0
- package/plugins/html/sample/components/service-tiles.html +73 -0
- package/plugins/html/sample/components/typography.html +42 -0
- package/plugins/html/sample/default.html +31 -0
- package/plugins/html/sample/favicon.ico +0 -0
- package/plugins/html/sample/images/black_puppy.jpg +0 -0
- package/plugins/html/sample/images/dolphin_marine_mammals_water.jpg +0 -0
- package/plugins/html/sample/images/grayscale_mountain.jpg +0 -0
- package/plugins/html/sample/images/silhouette.png +0 -0
- package/plugins/html/sample/images/squirrel_tail_bushy_tail.jpg +0 -0
- package/plugins/html/sample/index.html +48 -0
- package/plugins/html/sample/missing/content.html +4 -0
- package/plugins/html/sample/structural/branding.html +15 -0
- package/plugins/html/sample/structural/footer.html +47 -0
- package/plugins/html/sample/structural/header.html +16 -0
- package/plugins/html/sample/structural/mobile-controls.html +5 -0
- package/plugins/html/sample/structural/navigation.html +26 -0
- package/plugins/html/sample/structural/search.html +15 -0
- package/plugins/html/sample/structural/utility-header.html +23 -0
- package/plugins/html/scripts/create-entrypoints.js +62 -0
- package/plugins/html/scripts/icon.js +60 -0
- package/plugins/html/scripts/webpack.test.js +41 -0
- package/plugins/html/webpack.config.js +287 -0
- package/plugins/jshint/.jshintrc +31 -0
- package/plugins/jshint/README.md +26 -0
- package/plugins/jshint/changelog.txt +30 -0
- package/plugins/jshint/index.js +296 -0
- package/plugins/jshint/package-lock.json +1779 -0
- package/plugins/jshint/package.json +45 -0
- package/plugins/jshint/reporter.cjs +663 -0
- package/plugins/jshint/sample/jshint.css +247 -0
- package/plugins/jshint/sample/jshint.html +7 -0
- package/plugins/jshint/sample/jshint.js +25 -0
- package/plugins/jshint/sample/no-files.html +9 -0
- package/sample/index.html +364 -0
- package/scripts/update-deps.js +38 -0
- package/webpack.config.js +0 -54
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<footer class="global-footer">
|
|
2
|
+
<div class="container">
|
|
3
|
+
<div class="d-flex">
|
|
4
|
+
{{#if nav.footer }}
|
|
5
|
+
<ul class="nav footer-links">
|
|
6
|
+
<li class="nav-item">
|
|
7
|
+
<a href="https://www.ca.gov?utm_campaign=state_template_link&utm_medium=footer&utm_source=external" class="nav-link ps-0" title="CA.gov" target="_blank">
|
|
8
|
+
<span class="ca-gov-logo-svg"></span>
|
|
9
|
+
</a>
|
|
10
|
+
</li>
|
|
11
|
+
{{#each nav.footer }}
|
|
12
|
+
{{#if this.url }}{{#if this.label }}
|
|
13
|
+
<li class="nav-item">
|
|
14
|
+
<a href="{{ this.url }}" class="nav-link">{{ this.label }}</a>
|
|
15
|
+
</li>
|
|
16
|
+
{{/if}}{{/if}}
|
|
17
|
+
{{/each}}
|
|
18
|
+
</ul>
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if social }}
|
|
21
|
+
<ul class="nav social-share-links">
|
|
22
|
+
{{#each social }}
|
|
23
|
+
{{#if this }}
|
|
24
|
+
<li class="nav-item">
|
|
25
|
+
<a href="{{ this }}" class="nav-link ca-gov-icon-{{ @key }}"></a>
|
|
26
|
+
</li>
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{/each}}
|
|
29
|
+
</ul>
|
|
30
|
+
{{/if}}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<!-- Copyright Statement -->
|
|
34
|
+
<div class="copyright container">
|
|
35
|
+
<p>
|
|
36
|
+
©
|
|
37
|
+
<span id="thisyear">
|
|
38
|
+
<script>
|
|
39
|
+
document.getElementById('thisyear').appendChild(document.createTextNode(new Date().getFullYear()))
|
|
40
|
+
</script>
|
|
41
|
+
</span>
|
|
42
|
+
State of California
|
|
43
|
+
</p>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<button class="return-top">Back to top</button>
|
|
47
|
+
</footer>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<header role="banner" id="header" class="global-header">
|
|
2
|
+
<div id="skip-to-content">
|
|
3
|
+
<a href="#main-content">Skip to Main Content</a>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
{{> '../components/alerts.html' }}
|
|
7
|
+
|
|
8
|
+
{{> './utility-header.html' }}
|
|
9
|
+
|
|
10
|
+
{{> './branding.html' }}
|
|
11
|
+
|
|
12
|
+
{{> './mobile-controls.html' }}
|
|
13
|
+
|
|
14
|
+
{{> './navigation.html' }}
|
|
15
|
+
|
|
16
|
+
</header>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<!-- Mobile Navigation Controls -->
|
|
2
|
+
<div class="mobile-controlled overlay collapse collapse-horizontal">
|
|
3
|
+
<button class="mobile-control toggle-menu ca-gov-icon-close-mark fs-1" data-bs-toggle="collapse" data-bs-target=".mobile-controlled" aria-expanded="false" aria-controls="mobile-controls">
|
|
4
|
+
</button>
|
|
5
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Navigation -->
|
|
2
|
+
<div class="navigation border-bottom mobile-controlled collapse collapse-horizontal show">
|
|
3
|
+
<div class="container">
|
|
4
|
+
{{#if nav.header }}
|
|
5
|
+
<ul class="nav" aria-label="Main navigation">
|
|
6
|
+
{{#each nav.header }}
|
|
7
|
+
{{#if this.sub }}
|
|
8
|
+
<li class="nav-item dropdown">
|
|
9
|
+
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ this.label }}</a>
|
|
10
|
+
<ul class="dropdown-menu">
|
|
11
|
+
{{#each this.sub }}
|
|
12
|
+
<li class="nav-item">
|
|
13
|
+
<a class="nav-link" href="{{ this.url }}">{{ this.label }}</a>
|
|
14
|
+
</li>
|
|
15
|
+
{{/each}}
|
|
16
|
+
</ul>
|
|
17
|
+
{{else}}
|
|
18
|
+
<li class="nav-item">
|
|
19
|
+
<a class="nav-link" href="{{ this.url }}">{{ this.label }}</a>
|
|
20
|
+
{{/if}}
|
|
21
|
+
</li>
|
|
22
|
+
{{/each}}
|
|
23
|
+
</ul>
|
|
24
|
+
{{/if}}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{{#if google.search }}
|
|
2
|
+
<!-- Search -->
|
|
3
|
+
<div class="search-container">
|
|
4
|
+
<form action="/serp.html" role="search">
|
|
5
|
+
<div class="input-group">
|
|
6
|
+
<span class="sr-only" id="SearchInput">Custom Google Search</span>
|
|
7
|
+
<input type="search" name="q" aria-labelledby="SearchInput" placeholder="Search" class="search-textfield form-control">
|
|
8
|
+
<button type="submit" class="search-button">
|
|
9
|
+
<span class="ca-gov-icon-search" aria-hidden="true"></span>
|
|
10
|
+
<span class="sr-only">Submit</span>
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
</form>
|
|
14
|
+
</div>
|
|
15
|
+
{{/if}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!-- Utility Header -->
|
|
2
|
+
<div class="utility-header">
|
|
3
|
+
<div class="container d-flex flex-row">
|
|
4
|
+
<div class="social-media-links">
|
|
5
|
+
<div class="header-cagov-logo">
|
|
6
|
+
<a href="https://www.ca.gov?utm_campaign=state_template_link&utm_medium=header&utm_source=external">
|
|
7
|
+
<span class="sr-only">CA.gov</span>
|
|
8
|
+
<span class="ca-gov-logo-svg"></span>
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
<p class="official-tag">Official website of the State of California</p>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="settings-links">
|
|
14
|
+
{{#if utility-links }}
|
|
15
|
+
{{#each utility-links }}
|
|
16
|
+
{{#if this.url }}{{#if this.label }}
|
|
17
|
+
<a href="{{ this.url }}">{{ this.label }}</a>
|
|
18
|
+
{{/if}}{{/if}}
|
|
19
|
+
{{/each}}
|
|
20
|
+
{{/if}}
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const currentPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
|
|
12
|
+
let entry = {
|
|
13
|
+
'font-only': path.join(currentPath, 'src', 'styles', 'font-only.css')
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// create the entry directory
|
|
17
|
+
fs.mkdirSync('entry', {recursive: true});
|
|
18
|
+
|
|
19
|
+
let heading = `/**
|
|
20
|
+
* Autogenerated Entrypoint
|
|
21
|
+
* DO NOT MODIFY
|
|
22
|
+
*/\n`;
|
|
23
|
+
|
|
24
|
+
// iterate over all colorschemes
|
|
25
|
+
fs.readdirSync(path.join(currentPath, 'src', 'styles', 'colorschemes')).forEach((c) => {
|
|
26
|
+
let scheme = c.substring(0, c.indexOf('.')).replace(' ', '');
|
|
27
|
+
let files = [
|
|
28
|
+
path.join(currentPath, 'src', 'styles', 'font-only.css'),
|
|
29
|
+
path.join(currentPath, 'src', 'styles', 'colorschemes', c),
|
|
30
|
+
path.join(currentPath, 'src', 'scripts', 'index.js')
|
|
31
|
+
]
|
|
32
|
+
// add entries for each colorscheme
|
|
33
|
+
entry[scheme] = files;
|
|
34
|
+
|
|
35
|
+
let correctFiles = files.map(f => `'${f.replace(process.cwd(), '').replaceAll('\\', '/')}'`)
|
|
36
|
+
let output = `
|
|
37
|
+
import path from 'path';
|
|
38
|
+
import { fileURLToPath } from 'url';
|
|
39
|
+
const currentPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
entry: {
|
|
43
|
+
'font-only': path.join(currentPath, 'src', 'styles', 'font-only.css'),
|
|
44
|
+
${scheme}: [
|
|
45
|
+
path.join(currentPath, ${correctFiles.join('),\n' + `\t`.repeat(3) + 'path.join(currentPath, ')})
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// write and entrypoint
|
|
53
|
+
// this allows for serving of a specific entry.
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
`./entry/${scheme}.js`,
|
|
56
|
+
`${heading} ${output}`
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export default {entry};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const currentPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
const fontBuildPath = path.join(currentPath, 'build', 'fonts');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// iterate over all svg files
|
|
15
|
+
fs.readdirSync(fontBuildPath).filter( (e) => e.endsWith('.svg')).forEach((c) => {
|
|
16
|
+
|
|
17
|
+
// we can't use a parser otherwise some of the unicodes will be encoded
|
|
18
|
+
// we parse the file ourselves.
|
|
19
|
+
let svgContent = fs.readFileSync(path.join(fontBuildPath, c)).toString();
|
|
20
|
+
|
|
21
|
+
// we only want the glyph with unicodes
|
|
22
|
+
let icons = [ ...svgContent.matchAll(/glyph unicode=[^\n].*/g) ].map((i) => {
|
|
23
|
+
let raw = i[0];
|
|
24
|
+
let glyph = raw.match(/glyph-name="([\S]+)"/);
|
|
25
|
+
|
|
26
|
+
// only if there is a name associated with the glyph.
|
|
27
|
+
if( glyph ){
|
|
28
|
+
|
|
29
|
+
let unicode = raw.match(/unicode="([\S]+)"/)[1];
|
|
30
|
+
let name = glyph[1];
|
|
31
|
+
let ws = name.replace(/[_-]/g, ' ').split(' ');
|
|
32
|
+
|
|
33
|
+
// the styles is applied by certain editors/builders
|
|
34
|
+
// divi - Applies Divi Theme Support
|
|
35
|
+
// line - Applies Line Styles
|
|
36
|
+
// solid - Applied Solid Styles
|
|
37
|
+
let styles = [
|
|
38
|
+
'divi',
|
|
39
|
+
ws.includes('line') ? 'line' : 'solid'
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
glyph: name,
|
|
44
|
+
unicode,
|
|
45
|
+
name: ws.map(w => w.charAt(0).toUpperCase() + w.substring(1)).join(' '), // uppercase all words and join with a space
|
|
46
|
+
search_terms: ws.join(' '),
|
|
47
|
+
styles
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
}).filter(e=>e); // clear out any null values
|
|
53
|
+
|
|
54
|
+
// write svg json output
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
path.join(fontBuildPath, `${c.substring(0, c.lastIndexOf('.'))}.json`),
|
|
57
|
+
JSON.stringify( icons, null, 4 )
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import CAWebHTMLPlugin from '../index.js';
|
|
11
|
+
|
|
12
|
+
const componentDir = path.join(process.cwd(), 'sample', 'components');
|
|
13
|
+
|
|
14
|
+
let plugins = [];
|
|
15
|
+
|
|
16
|
+
fs.readdirSync(componentDir).forEach((c) => {
|
|
17
|
+
let p = fs.readFileSync( path.join(componentDir, c) ).toString();
|
|
18
|
+
let t = c.replace(/\.*/, '').replace('-', ' ');
|
|
19
|
+
|
|
20
|
+
plugins.push(
|
|
21
|
+
new CAWebHTMLPlugin({
|
|
22
|
+
filename: `components/${c}`,
|
|
23
|
+
title: t.charAt(0).toUpperCase() + t.substring(1),
|
|
24
|
+
templateParameters: {
|
|
25
|
+
scheme: false, // we use the entrypoints for testing
|
|
26
|
+
bodyHtmlSnippet: p,
|
|
27
|
+
},
|
|
28
|
+
skipAssets: [
|
|
29
|
+
/.*-rtl.css/, // we skip the Right-to-Left Styles
|
|
30
|
+
/css-audit.*/, // we skip the CSSAudit Files
|
|
31
|
+
/a11y.*/, // we skip the A11y Files
|
|
32
|
+
/jshint.*/, // we skip the JSHint Files
|
|
33
|
+
/font-only.*/, // we skip the font-only Files
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
plugins
|
|
41
|
+
};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebPack Configuration for California Department of Technology
|
|
3
|
+
*
|
|
4
|
+
* Utilizes WordPress Scripts Webpack configuration as base.
|
|
5
|
+
*
|
|
6
|
+
* @link https://webpack.js.org/configuration/
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* External Dependencies
|
|
11
|
+
*/
|
|
12
|
+
import baseConfig from '@wordpress/scripts/config/webpack.config.js';
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
|
|
17
|
+
// webpack plugins
|
|
18
|
+
import MiniCSSExtractPlugin from 'mini-css-extract-plugin';
|
|
19
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
20
|
+
import RtlCssPlugin from 'rtlcss-webpack-plugin';
|
|
21
|
+
import {HtmlWebpackSkipAssetsPlugin} from 'html-webpack-skip-assets-plugin';
|
|
22
|
+
import {HtmlWebpackLinkTypePlugin} from 'html-webpack-link-type-plugin';
|
|
23
|
+
|
|
24
|
+
import JSHintPlugin from '@caweb/jshint-webpack-plugin';
|
|
25
|
+
import CSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
|
|
26
|
+
import A11yPlugin from '@caweb/a11y-webpack-plugin';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
import CAWebHTMLPlugin from './index.js';
|
|
32
|
+
|
|
33
|
+
const webpackCommand = 'build' === process.argv[2] ? 'build' : 'serve' ;
|
|
34
|
+
|
|
35
|
+
// flags can be passed via argv0
|
|
36
|
+
// we also add args from NODE_OPTIONS
|
|
37
|
+
const flags = [].concat(
|
|
38
|
+
processArgs(process.argv),
|
|
39
|
+
processArgs(process.argv0.split(' ')),
|
|
40
|
+
processArgs(process.env.NODE_OPTIONS ? process.env.NODE_OPTIONS.split(' ') : [])
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
function processArgs( arr ){
|
|
44
|
+
let tmp = [];
|
|
45
|
+
|
|
46
|
+
arr.filter(Boolean).map((o) => {
|
|
47
|
+
return o.replaceAll("'", '').split('=').forEach((e => tmp.push(e)))
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return tmp
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function flagExists(flag){
|
|
54
|
+
return flags.includes(flag)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getArgVal(flag){
|
|
58
|
+
return flagExists(flag) ? flags[flags.indexOf(flag) + 1] : false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Update some of the default WordPress webpack rules.
|
|
62
|
+
baseConfig.module.rules.forEach((rule, i) => {
|
|
63
|
+
const r = new RegExp(rule.test).toString();
|
|
64
|
+
|
|
65
|
+
switch(r){
|
|
66
|
+
// WordPress adds a hash to asset file names we remove that hash.
|
|
67
|
+
case new RegExp(/\.(bmp|png|jpe?g|gif|webp)$/i).toString():
|
|
68
|
+
rule.generator.filename = 'images/[name][ext]';
|
|
69
|
+
break;
|
|
70
|
+
case new RegExp(/\.(woff|woff2|eot|ttf|otf)$/i).toString():
|
|
71
|
+
rule.generator.filename = 'fonts/[name][ext]';
|
|
72
|
+
break;
|
|
73
|
+
case new RegExp(/\.svg$/).toString():
|
|
74
|
+
// we don't want SVG to be asset/inline otherwise the resource may not be available.
|
|
75
|
+
// the asset should be an asset/resource we move them to the fonts folder.
|
|
76
|
+
if( 'asset/inline' === rule.type ){
|
|
77
|
+
rule.type = 'asset/resource';
|
|
78
|
+
rule.generator = { filename: 'fonts/[name][ext]' };
|
|
79
|
+
|
|
80
|
+
delete rule.issuer;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// we remove the WordPress CleanWebpackPlugin definition
|
|
87
|
+
// instead we use the Webpack output.clean definition
|
|
88
|
+
baseConfig.plugins.splice(1,1, false);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* we remove the WordPress devServer declaration since we can only have 1 when exporting multiple configurations
|
|
92
|
+
*
|
|
93
|
+
* @see https://github.com/webpack/webpack-cli/issues/2408#issuecomment-793052542
|
|
94
|
+
*/
|
|
95
|
+
delete baseConfig.devServer;
|
|
96
|
+
|
|
97
|
+
// Wordpress ignores the webpack --mode flag
|
|
98
|
+
// if the flag is passed we use that mode
|
|
99
|
+
// otherwise use whatever Wordpress is using
|
|
100
|
+
let mode = getArgVal('--mode') ? getArgVal('--mode') : baseConfig.mode;
|
|
101
|
+
|
|
102
|
+
let webpackConfig = {
|
|
103
|
+
...baseConfig,
|
|
104
|
+
mode,
|
|
105
|
+
name: 'uncompressed',
|
|
106
|
+
target: 'web',
|
|
107
|
+
cache: false,
|
|
108
|
+
stats: 'errors',
|
|
109
|
+
output: {
|
|
110
|
+
...baseConfig.output,
|
|
111
|
+
clean: mode === 'production'
|
|
112
|
+
},
|
|
113
|
+
performance: {
|
|
114
|
+
maxAssetSize: 500000,
|
|
115
|
+
maxEntrypointSize: 500000
|
|
116
|
+
},
|
|
117
|
+
module:{
|
|
118
|
+
...baseConfig.module,
|
|
119
|
+
rules: [
|
|
120
|
+
...baseConfig.module.rules,
|
|
121
|
+
/**
|
|
122
|
+
* Default template loader for html is lodash,
|
|
123
|
+
* lets switch to handlebars
|
|
124
|
+
*/
|
|
125
|
+
{
|
|
126
|
+
test: /\.html$/,
|
|
127
|
+
loader: 'handlebars-loader',
|
|
128
|
+
options:{
|
|
129
|
+
rootRelative: process.cwd(),
|
|
130
|
+
partialResolver: function(partial, callback){
|
|
131
|
+
/**
|
|
132
|
+
* All template partials are loaded from the root sample directory
|
|
133
|
+
* if the file doesn't exist we fallback to our sample template partials
|
|
134
|
+
*/
|
|
135
|
+
let partialPath = path.join( process.cwd(), 'sample' );
|
|
136
|
+
let partialStructurePath = path.join( partialPath, 'structural' );
|
|
137
|
+
|
|
138
|
+
// template parameter specific partials
|
|
139
|
+
switch( partial ){
|
|
140
|
+
// header/footer is served from the /sample/structural/ directory
|
|
141
|
+
case 'footer':
|
|
142
|
+
case 'header':
|
|
143
|
+
partialPath = fs.existsSync(path.join( partialStructurePath, `/${partial}.html` )) ? path.join( partialStructurePath, `/${partial}.html` ) :
|
|
144
|
+
`./structural/${partial}.html`
|
|
145
|
+
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case 'content':
|
|
149
|
+
// content is served from /sample/index.html
|
|
150
|
+
partialPath = fs.existsSync(path.join( partialPath, '/index.html' )) ? path.join( partialPath, '/index.html' ) :
|
|
151
|
+
'./missing/content.html';
|
|
152
|
+
|
|
153
|
+
break;
|
|
154
|
+
|
|
155
|
+
// if not a template parameter we let the loader handle it
|
|
156
|
+
default:
|
|
157
|
+
partialPath = partial;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
callback(false, partialPath );
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Serve Only
|
|
171
|
+
*/
|
|
172
|
+
if( 'serve' === webpackCommand ){
|
|
173
|
+
const appPath = process.cwd();
|
|
174
|
+
let template = flags.includes('--template') ? getArgVal('--template') : 'default';
|
|
175
|
+
let scheme = flags.includes('--scheme') ? getArgVal('--scheme') : 'oceanside';
|
|
176
|
+
|
|
177
|
+
// Dev Server is added
|
|
178
|
+
webpackConfig.devServer = {
|
|
179
|
+
devMiddleware: {
|
|
180
|
+
writeToDisk: true,
|
|
181
|
+
},
|
|
182
|
+
hot: true,
|
|
183
|
+
compress: true,
|
|
184
|
+
allowedHosts: 'auto',
|
|
185
|
+
host: 'localhost',
|
|
186
|
+
port: 9000,
|
|
187
|
+
open: [ 'http://localhost:9000' ],
|
|
188
|
+
static: [
|
|
189
|
+
/**
|
|
190
|
+
* Static files are served from the following files in the following order
|
|
191
|
+
* we don't have to add the build directory since that is the output.path and proxied
|
|
192
|
+
* public - Default
|
|
193
|
+
* sample - Allows loading sample files
|
|
194
|
+
* node_modules - Allows loading files from other npm packages
|
|
195
|
+
* src - Allows loading files that aren't compiled
|
|
196
|
+
*/
|
|
197
|
+
{
|
|
198
|
+
directory: path.join(appPath, 'public'),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
directory: path.join(appPath, 'sample'),
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
directory: path.join(appPath, 'node_modules'),
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
directory: path.join(appPath, 'src'),
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
proxy:[
|
|
211
|
+
/**
|
|
212
|
+
* WordPress Proxy Configuration is deprecated
|
|
213
|
+
* @since 28.2.0
|
|
214
|
+
*/
|
|
215
|
+
{
|
|
216
|
+
context: ['/build'],
|
|
217
|
+
target: 'http://localhost:9000',
|
|
218
|
+
pathRewrite: {
|
|
219
|
+
'^/build': ''
|
|
220
|
+
},
|
|
221
|
+
logLevel: 'info'
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* We proxy the node_modules and src so they serve from the root
|
|
225
|
+
*/
|
|
226
|
+
{
|
|
227
|
+
context: ['/node_modules'],
|
|
228
|
+
target: 'http://localhost:9000',
|
|
229
|
+
pathRewrite: { '^/node_modules': '' },
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
context: ['/src'],
|
|
233
|
+
target: 'http://localhost:9000',
|
|
234
|
+
pathRewrite: { '^/src': '' },
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Page Template and additional plugins
|
|
240
|
+
webpackConfig.plugins.push(
|
|
241
|
+
new CAWebHTMLPlugin({
|
|
242
|
+
template,
|
|
243
|
+
templateParameters: {
|
|
244
|
+
scheme: 'false' !== scheme ? scheme : false
|
|
245
|
+
},
|
|
246
|
+
skipAssets: [
|
|
247
|
+
/.*-rtl.css/, // we skip the Right-to-Left Styles
|
|
248
|
+
/css-audit.*/, // we skip the CSSAudit Files
|
|
249
|
+
/a11y.*/, // we skip the A11y Files
|
|
250
|
+
/jshint.*/, // we skip the JSHint Files
|
|
251
|
+
/font-only.js/, // we skip the font-only Files
|
|
252
|
+
]
|
|
253
|
+
}),
|
|
254
|
+
new HtmlWebpackSkipAssetsPlugin(),
|
|
255
|
+
new HtmlWebpackLinkTypePlugin(),
|
|
256
|
+
! flagExists('--no-jshint') ? new JSHintPlugin() : false,
|
|
257
|
+
! flagExists('--no-audit') ? new CSSAuditPlugin() : false,
|
|
258
|
+
! flagExists('--no-a11y') ? new A11yPlugin() : false
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Production only
|
|
264
|
+
*/
|
|
265
|
+
if( mode === 'production' ){
|
|
266
|
+
// Config
|
|
267
|
+
webpackConfig.name = 'compressed';
|
|
268
|
+
webpackConfig.devtool = false;
|
|
269
|
+
|
|
270
|
+
// Output
|
|
271
|
+
webpackConfig.output.filename = '[name].min.js';
|
|
272
|
+
webpackConfig.output.chunkFilename = '[name].min.js?v=[chunkhash]';
|
|
273
|
+
|
|
274
|
+
// Plugins
|
|
275
|
+
webpackConfig.plugins.push(
|
|
276
|
+
new MiniCSSExtractPlugin( { filename: '[name].min.css' } ),
|
|
277
|
+
new RtlCssPlugin( { filename: '[name]-rtl.min.css' } )
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
// Optimization
|
|
281
|
+
webpackConfig.optimization.minimize = true;
|
|
282
|
+
webpackConfig.optimization.minimizer.push(
|
|
283
|
+
new CssMinimizerPlugin({test: /\.min\.css$/})
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export default webpackConfig;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"boss": true,
|
|
3
|
+
"curly": true,
|
|
4
|
+
"eqeqeq": true,
|
|
5
|
+
"eqnull": true,
|
|
6
|
+
"esversion": 11,
|
|
7
|
+
"expr": true,
|
|
8
|
+
"immed": true,
|
|
9
|
+
"noarg": true,
|
|
10
|
+
"nonbsp": true,
|
|
11
|
+
"quotmark": "single",
|
|
12
|
+
"undef": true,
|
|
13
|
+
"unused": true,
|
|
14
|
+
|
|
15
|
+
"browser": true,
|
|
16
|
+
|
|
17
|
+
"globals": {
|
|
18
|
+
"_": false,
|
|
19
|
+
"Backbone": false,
|
|
20
|
+
"jQuery": false,
|
|
21
|
+
"JSON": false,
|
|
22
|
+
"wp": false,
|
|
23
|
+
"export": false,
|
|
24
|
+
"module": false,
|
|
25
|
+
"require": false,
|
|
26
|
+
"WorkerGlobalScope": false,
|
|
27
|
+
"self": false,
|
|
28
|
+
"OffscreenCanvas": false,
|
|
29
|
+
"Promise": false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
This is a Webpack Plugin that utilizes [JSHint](https://www.npmjs.com/package/jshint) to detect errors and potential problems in Javascript code.
|
|
2
|
+
|
|
3
|
+
The JSHint Settings used are an adapation of the [WordPress JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/). The default WordPress JSHint Settings can be viewed [here](https://develop.svn.wordpress.org/trunk/.jshintrc).
|
|
4
|
+
|
|
5
|
+
Our standard differs from the guidelines in the following ways:
|
|
6
|
+
- ESVersion has been updated from 6 to 11
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
<pre>npm install --save-dev @caweb/jshint-webpack-plugin</pre>
|
|
12
|
+
|
|
13
|
+
## Get Started
|
|
14
|
+
In your Webpack configuration simply add the plugin to your existing plugin array.
|
|
15
|
+
|
|
16
|
+
<pre>
|
|
17
|
+
import CSSAuditPlugin from '@caweb/css-audit-webpack-plugin';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
plugins: [
|
|
21
|
+
new JSHintPlugin()
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
</pre>
|
|
25
|
+
|
|
26
|
+
## Options
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
v1.0.9
|
|
2
|
+
- Update npm packages
|
|
3
|
+
- Added npm devDependencies packages
|
|
4
|
+
|
|
5
|
+
v1.0.8
|
|
6
|
+
- Updated Readme
|
|
7
|
+
|
|
8
|
+
v1.0.7
|
|
9
|
+
- Fixed issue with hot module replacement not loading
|
|
10
|
+
|
|
11
|
+
v1.0.6
|
|
12
|
+
- Added sample file for when no files are reported
|
|
13
|
+
|
|
14
|
+
v1.0.5
|
|
15
|
+
- Added a11y and css-audit HRM update file to ignore list
|
|
16
|
+
|
|
17
|
+
v1.0.4
|
|
18
|
+
- Updated jshint esversion from 6 to
|
|
19
|
+
|
|
20
|
+
v1.0.3
|
|
21
|
+
- Fixed issue with hot module replacement
|
|
22
|
+
|
|
23
|
+
v1.0.2
|
|
24
|
+
- Fixed issue with hot module replacement
|
|
25
|
+
|
|
26
|
+
v1.0.1
|
|
27
|
+
- Fixed issue with reporter file missing
|
|
28
|
+
|
|
29
|
+
v1.0.0
|
|
30
|
+
- JSHint Webpack Plugin
|