@caweb/a11y-webpack-plugin 1.0.1 → 1.0.3
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/index.js +30 -41
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -85,7 +85,7 @@ class A11yPlugin {
|
|
|
85
85
|
const { entry, options, context } = {
|
|
86
86
|
entry: path.join( this.config.outputFolder, 'a11y.update.js'),
|
|
87
87
|
options: {
|
|
88
|
-
name: 'a11y'
|
|
88
|
+
name: 'a11y.update'
|
|
89
89
|
},
|
|
90
90
|
context: 'a11y'
|
|
91
91
|
};
|
|
@@ -122,47 +122,36 @@ class A11yPlugin {
|
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
compiler.hooks.done.tapAsync(
|
|
126
|
-
'IBM Accessibility Plugin',
|
|
127
|
-
/**
|
|
128
|
-
* Hook into the process assets hook
|
|
129
|
-
* @param {any} _
|
|
130
|
-
* @param {(err?: Error) => void} callback
|
|
131
|
-
*/
|
|
132
|
-
({compilation}, callback) => {
|
|
133
|
-
|
|
134
|
-
console.log(`<i> ${boldGreen('[webpack-dev-middleware] Running IBM Accessibility scan...')}`);
|
|
135
|
-
|
|
136
|
-
let result = this.a11yCheck(path.join(process.cwd(), output.publicPath ?? '/' ), this.config );
|
|
137
|
-
|
|
138
|
-
if( result ){
|
|
139
|
-
// we have to inject the a11y.update.js file into the head in order for the webpack-dev-server scripts to load.
|
|
140
|
-
let pageContent = fs.readFileSync(path.join(staticDir.directory, `${this.config.outputFilename}.html`))
|
|
141
|
-
|
|
142
|
-
fs.writeFileSync(
|
|
143
|
-
path.join(staticDir.directory, `${this.config.outputFilename}.html`),
|
|
144
|
-
pageContent.toString().replace('</head>', '<script src="/a11y.update.js"></script>\n</head>')
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
console.log(`<i> ${boldGreen('[webpack-dev-middleware] IBM Accessibilty Report can be viewed at')} ${ boldBlue(new URL(`${hostUrl}/${this.config.outputFilename}.html`).toString()) }`);
|
|
149
|
-
|
|
150
|
-
callback();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
compiler.hooks.watchClose.tap( 'IBM Accessibility Plugin', () => {
|
|
154
|
-
getAllFilesSync(compiler.options.output.path).toArray().forEach(f => {
|
|
155
|
-
if(
|
|
156
|
-
f.includes('a11y') || // delete any a11y files
|
|
157
|
-
f.includes('.hot-update.js') // delete any HMR files
|
|
158
|
-
){
|
|
159
|
-
fs.rmSync(f)
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
});
|
|
163
|
-
|
|
164
125
|
});
|
|
165
126
|
|
|
127
|
+
compiler.hooks.done.tapAsync(
|
|
128
|
+
'IBM Accessibility Plugin',
|
|
129
|
+
/**
|
|
130
|
+
* Hook into the process assets hook
|
|
131
|
+
* @param {any} _
|
|
132
|
+
* @param {(err?: Error) => void} callback
|
|
133
|
+
*/
|
|
134
|
+
(stats, callback) => {
|
|
135
|
+
|
|
136
|
+
console.log(`<i> ${boldGreen('[webpack-dev-middleware] Running IBM Accessibility scan...')}`);
|
|
137
|
+
|
|
138
|
+
let result = this.a11yCheck(path.join(process.cwd(), 'auto' === output.publicPath ? 'public' : output.publicPath ), this.config );
|
|
139
|
+
|
|
140
|
+
if( result ){
|
|
141
|
+
// we have to inject the a11y.update.js file into the head in order for the webpack-dev-server scripts to load.
|
|
142
|
+
let pageContent = fs.readFileSync(path.join(staticDir.directory, `${this.config.outputFilename}.html`))
|
|
143
|
+
|
|
144
|
+
fs.writeFileSync(
|
|
145
|
+
path.join(staticDir.directory, `${this.config.outputFilename}.html`),
|
|
146
|
+
pageContent.toString().replace('</head>', `<script src="${compiler.options.output.publicPath}/a11y.update.js"></script>\n</head>`)
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
console.log(`<i> ${boldGreen('[webpack-dev-middleware] IBM Accessibilty Report can be viewed at')} ${ boldBlue(new URL(`${hostUrl}/${this.config.outputFilename}.html`).toString()) }`);
|
|
151
|
+
|
|
152
|
+
callback();
|
|
153
|
+
});
|
|
154
|
+
|
|
166
155
|
});
|
|
167
156
|
|
|
168
157
|
}
|
|
@@ -194,7 +183,7 @@ class A11yPlugin {
|
|
|
194
183
|
outputFolder,
|
|
195
184
|
outputFilenameTimestamp
|
|
196
185
|
}){
|
|
197
|
-
|
|
186
|
+
console.log( url )
|
|
198
187
|
let acheckerArgs = [
|
|
199
188
|
'--ruleArchive',
|
|
200
189
|
ruleArchive,
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/a11y-webpack-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CAWebPublishing Webpack Plugin to run Accessibility Scans",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"aceconfig.js",
|
|
9
|
-
"index.js"
|
|
9
|
+
"index.js",
|
|
10
|
+
"README.md"
|
|
10
11
|
],
|
|
11
12
|
"scripts": {
|
|
12
13
|
"test": "echo \"Error: run tests from root\" && exit 0"
|