diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18184d8..51376ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,9 @@ jobs: html-webpack: 5 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.webpack < 5 && '16.20.2' || '20.8.0' }} - run: npm install - run: npm install -D webpack@${{ matrix.webpack }} html-webpack-plugin@${{ matrix.html-webpack }} - run: npm run test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 16b615f..d2f7a38 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,18 +5,10 @@ on: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - webpack: [4] - html-webpack: [4, 3] - include: - - webpack: 5 - html-webpack: 5 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 - run: npm install - - run: npm install -D webpack@${{ matrix.webpack }} html-webpack-plugin@${{ matrix.html-webpack }} - run: npm run test - run: npm run build deploy: @@ -24,7 +16,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 + with: + node-version: '20.8.0' - run: npm install - uses: JS-DevTools/npm-publish@v1 with: diff --git a/package.json b/package.json index 3cc6f87..21fd08b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-webpack-skip-assets-plugin", - "version": "1.0.3", + "version": "1.0.4", "description": "a plugin for html-webpack-plugin to skip adding certain output files to the html", "repository": { "type": "git", @@ -14,7 +14,7 @@ "scripts": { "test": "mocha -r ts-node/register spec/**/*.spec.ts --exit", "prebuild": "rimraf dist", - "build": "tsc", + "build": "tsc -p tsconfig.json", "prepublishOnly": "npm run build" }, "keywords": [ @@ -30,7 +30,7 @@ "devDependencies": { "@types/chai": "4.2.14", "@types/mocha": "8.2.0", - "@types/node": "13.13.4", + "@types/node": "20.11.30", "chai": "4.2.0", "css-loader": "5.0.1", "html-webpack-plugin": ">=3.2.0", @@ -38,7 +38,7 @@ "mocha": "8.2.1", "rimraf": "3.0.2", "ts-node": "9.1.1", - "typescript": "4.1.3", + "typescript": "5.4.3", "webpack": ">=3.0.0" }, "dependencies": { diff --git a/spec/index.spec.ts b/spec/index.spec.ts index a46024b..e3b4877 100644 --- a/spec/index.spec.ts +++ b/spec/index.spec.ts @@ -102,7 +102,7 @@ configs.forEach(c => { it('should do nothing when no patterns are specified', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin(), ] @@ -120,7 +120,7 @@ configs.forEach(c => { it('should not fail on meta links', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, meta: { @@ -133,7 +133,7 @@ configs.forEach(c => { ] }, (err, stats) => { expect(!!err).to.be.false; - expect(stats.hasErrors()).to.be.false; + expect(stats?.hasErrors()).to.be.false; const html = getOutput(); expect(/script\s+.*?src\s*=\s*"(\/)?polyfill(\.[a-z0-9]+\.min)?\.js"/i.test(html), 'could not find polyfill bundle').to.be.true; expect(/script\s+.*?src\s*=\s*"(\/)?app(\.[a-z0-9]+\.min)?\.js"/i.test(html), 'could not find app bundle').to.be.true; @@ -147,7 +147,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.skipAssets.minimatch', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ skipAssets: ['styles**.js'] @@ -167,7 +167,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.excludeAssets.minimatch', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ excludeAssets: ['styles**.js'] @@ -187,7 +187,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.skipAssets.regex', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ skipAssets: [/styles\..*js/i] @@ -207,7 +207,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.excludeAssets.regex', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ excludeAssets: [/styles\..*js/i] @@ -227,7 +227,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.skipAssets.regex-global', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ skipAssets: [/styles\./gi] @@ -247,7 +247,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.excludeAssets.regex-global', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ excludeAssets: [/styles\./gi] @@ -267,7 +267,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.skipAssets.callback', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ skipAssets: [(asset) => { @@ -291,7 +291,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - plugin.excludeAssets.callback', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin(HtmlWebpackPluginOptions), new HtmlWebpackSkipAssetsPlugin({ excludeAssets: [(asset) => { @@ -315,7 +315,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.skipAssets.minimatch', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, skipAssets: ['styles**.js'] @@ -336,7 +336,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.excludeAssets.minimatch', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, excludeAssets: ['styles**.js'] @@ -357,7 +357,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.skipAssets.regex', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, skipAssets: [/styles\..*js/i] @@ -378,7 +378,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.excludeAssets.regex', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, excludeAssets: [/styles\..*js/i] @@ -399,7 +399,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.skipAssets.regex-global', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, skipAssets: [/styles\./gi] @@ -420,7 +420,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.excludeAssets.regex-global', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, excludeAssets: [/styles\./gi] @@ -441,7 +441,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.skipAssets.callback', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, skipAssets: [(asset) => { @@ -466,7 +466,7 @@ configs.forEach(c => { it('should skip adding asset if the pattern matches - parent.excludeAssets.callback', (done) => { webpack({ ...c.options, plugins: [ - ...c.options.plugins, + ...c.options.plugins ?? [], new HtmlWebpackPlugin({ ...HtmlWebpackPluginOptions, excludeAssets: [(asset) => { diff --git a/tsconfig.json b/tsconfig.json index 199fb55..f8827f8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,9 +14,10 @@ ] }, "exclude": [ - "node_modules/", + "**/node_modules/", "spec/", "**/*.spec.js", "**/*.spec.ts", + "**/*.d.ts" ] }