diff --git a/.eslintrc b/.eslintrc index 23b4944..f19a342 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,7 +39,7 @@ }, "overrides": [ { - "files": ["scripts/*.js"], + "files": ["scripts/*.js", "test/**/*.js"], "env": { "node": true }, "rules": { "@typescript-eslint/no-var-requires": ["off"], diff --git a/.github/workflows/pull-request.yml b/.github/workflows/ci.yml similarity index 68% rename from .github/workflows/pull-request.yml rename to .github/workflows/ci.yml index 6d72692..97f9914 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,18 @@ -name: Build test -on: [pull_request] +name: ci +on: + push: + branches: + - master + - develop + tags-ignore: + - '**' #prevent double build on release tag + pull_request: + branches: + - '**' jobs: - check: - name: Build + test: + name: Test runs-on: ubuntu-18.04 steps: - name: Checkout repo @@ -23,9 +32,15 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- + - name: Install webpack-cli + run: | + yarn add -P webpack-cli - name: Install dependencies run: | yarn install --frozen-lockfile - - name: Build + - name: Build package run: | yarn build + - name: Test + run: | + webpack --config test/cases/v4/simple/webpack.config.js diff --git a/.gitignore b/.gitignore index 259e5ed..d922645 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ yarn-debug.log* yarn-error.log* /dist +/test/**/*/dist diff --git a/.npmignore b/.npmignore index a5a4292..c5fa177 100755 --- a/.npmignore +++ b/.npmignore @@ -12,3 +12,4 @@ yarn-error.log yarn.lock .github lgtm.yml +/test diff --git a/README.md b/README.md index 48f8791..4083877 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest version](https://img.shields.io/github/v/release/icelam/html-inline-script-webpack-plugin.svg?sort=semver&label=latest)](https://github.com/icelam/html-inline-script-webpack-plugin/releases) [![Download count](https://img.shields.io/npm/dm/html-inline-script-webpack-plugin)](https://www.npmjs.com/package/html-inline-script-webpack-plugin) [![Install size](https://packagephobia.com/badge?p=html-inline-script-webpack-plugin)](https://packagephobia.com/result?p=html-inline-script-webpack-plugin) -![Build test](https://github.com/icelam/html-inline-script-webpack-plugin/workflows/Build%20test/badge.svg) +![ci](https://github.com/icelam/html-inline-script-webpack-plugin/workflows/ci/badge.svg) [![Package quality](https://npm.packagequality.com/shield/html-inline-script-webpack-plugin.svg)](https://packagequality.com/#?package=html-inline-script-webpack-plugin) A webpack plugin for converting external script files `` to inline script block ``. Requires [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) to work. diff --git a/test/cases/v4/simple/index.html b/test/cases/v4/simple/index.html new file mode 100644 index 0000000..c061c8e --- /dev/null +++ b/test/cases/v4/simple/index.html @@ -0,0 +1,14 @@ + + + + + + + + + webpack test + + +

This is minimal code to demonstrate webpack usage

+ + diff --git a/test/cases/v4/simple/index.js b/test/cases/v4/simple/index.js new file mode 100644 index 0000000..2ce7e4a --- /dev/null +++ b/test/cases/v4/simple/index.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line no-console +console.log('Hello world'); diff --git a/test/cases/v4/simple/webpack.config.js b/test/cases/v4/simple/webpack.config.js new file mode 100644 index 0000000..a330e8e --- /dev/null +++ b/test/cases/v4/simple/webpack.config.js @@ -0,0 +1,18 @@ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const Self = require('../../../../dist'); + +module.exports = { + mode: 'production', + entry: path.join(__dirname, './index.js'), + output: { + path: path.join(__dirname, './dist'), + filename: 'index.js' + }, + plugins: [ + new HtmlWebpackPlugin({ + template: path.resolve(__dirname, './index.html') + }), + new Self() + ] +};