Skip to content

Bump ini from 1.3.5 to 1.3.8 in /test/e2e/webpack1 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = {
env: {
node: true,
es6: true,
jest: true
jest: true,
},
parserOptions: {
ecmaVersion: 2017
ecmaVersion: 2021,
},
rules: {
"no-unused-vars": "warn"
}
"no-unused-vars": "warn",
},
};
25 changes: 25 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code quality

on:
push:
paths:
- ".github/**"
- "yarn.lock"
- "**.js"

jobs:
test_and_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/cache@master
id: node_modules_cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- run: yarn install --frozen-lockfile
if: steps.node_modules_cache.outputs.cache-hit != 'true'

- run: yarn e2e
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sudo: false
language: node_js
node_js:
- "10"
- "8"
- "14"
- "12"
install:
- yarn
- yarn install --frozen-lockfile
script:
- yarn e2e
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This project adheres to [Semantic Versioning](http://semver.org/).

## 3.0.0

- Drop support node v8
- Update `loader-utils` to the latest version
- Update webpack peer dependencies limit (thanks [@daniele-orlando][https://github.com/daniele-orlando] [#15](https://github.com/retyui/clean-css-loader/issues/15))
- Update dev dependency
- Update webpack e2e tests from `webpack@4` => `webpack@5`

## 2.0.0

- Drop support node v6
Expand Down
90 changes: 46 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div align="center">
<img src="https://cdn.rawgit.com/jakubpawlowicz/clean-css/master/logo.v2.svg" alt="clean-css logo" width="500"/>
<img src="https://cdn.rawgit.com/jakubpawlowicz/clean-css/master/logo.v2.svg" alt="clean-css logo" width="400"/>
<br>
<a href="https://github.com/webpack/webpack">
<img width="200" height="200"
src="https://webpack.js.org/assets/icon-square-big.svg">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
</div>

Expand Down Expand Up @@ -31,32 +30,35 @@ Use the loader either via your webpack config, CLI or inline.
**webpack.config.js**

```js
const production = false;

const cssUseList = ["style-loader", "css-loader"];

if (production) {
cssUseList.push("clean-css-loader");
// or with options
cssUseList.push({
loader: "clean-css-loader",
options: {
compatibility: "ie9",
level: 2,
inline: ["remote"]
}
});
const isProductionMode = process.env.NODE_ENV === "production";

const cssLoaders = ["style-loader", "css-loader"];

if (isProductionMode) {
// push loader for production mode only
cssLoaders.push("clean-css-loader");

// exmaple with options
cssLoaders.push({
loader: "clean-css-loader",
options: {
compatibility: "ie9",
level: 2,
inline: ["remote"],
},
});
}

module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: cssUseList
}
]
}
mode: isProductionMode ? "production" : "development",
module: {
rules: [
{
test: /\.css$/,
use: cssLoaders,
},
],
},
};
```

Expand Down Expand Up @@ -100,23 +102,23 @@ More option: [https://github.com/jakubpawlowicz/clean-css#constructor-options](h

```js
module.exports = {
module: {
loaders: [
{
test: /\.css$/,
loader: "css!clean-css"
},
{
test: /\.styl$/,
loader: "css!clean-css!stylus?reslve url"
}
//...
],
// Example Set options (Key "clean-css" or cleancss or CleanCSS):
"clean-css": {
debug: true,
mediaMerging: true
}
}
module: {
loaders: [
{
test: /\.css$/,
loader: "css!clean-css",
},
{
test: /\.styl$/,
loader: "css!clean-css!stylus?reslve url",
},
//...
],
// Example Set options (Key "clean-css" or cleancss or CleanCSS):
"clean-css": {
debug: true,
mediaMerging: true,
},
},
};
```
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ os: Visual Studio 2017
platform: x64
environment:
matrix:
- nodejs_version: "10"
- nodejs_version: "8"
- nodejs_version: "14"
- nodejs_version: "12"

install:
- ps: Install-Product node $env:nodejs_version x64
- yarn install
- yarn install --frozen-lockfile

test_script:
- node --version
Expand Down
13 changes: 2 additions & 11 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "8.9.0"
}
}
]
],
plugins: ["babel-plugin-add-module-exports"]
presets: [["@babel/preset-env", { targets: { node: "10.13.0" } }]],
plugins: ["babel-plugin-add-module-exports"],
};
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
linters: {
"./**/*.js": ["prettier", "eslint --fix", "git add"],
"./**/*.css": ["prettier", "git add"]
"./**/*.css": ["prettier", "git add"],
},
ignore: ["test/e2e/**/*.test.js"]
ignore: ["test/e2e/**/*.test.js"],
};
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "clean-css-loader",
"version": "2.0.0",
"version": "3.0.0",
"main": "lib/index.js",
"dependencies": {
"clean-css": "^4.2.1",
"loader-utils": "^1.2.3"
"clean-css": "^4.2.3",
"loader-utils": "^2.0.0"
},
"peerDependencies": {
"webpack": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0"
"webpack": ">=1.0.0"
},
"scripts": {
"e2e": "yarn build && yarn update-e2e && yarn test",
"force-clean": "rimraf ./test/e2e/webpack*/node_modules/ ./test/e2e/webpack*/tests/**/*.test.js",
"install-sub": "yarn link && cd ./test/e2e/webpack1 && yarn && yarn link clean-css-loader && yarn build && cd ../webpack4 && yarn && yarn link clean-css-loader && yarn build && cd ../../..",
"install-sub": "yarn link && cd ./test/e2e/webpack1 && yarn && yarn link clean-css-loader && yarn build && cd ../webpack5 && yarn && yarn link clean-css-loader && yarn build && cd ../../..",
"update-e2e": "yarn force-clean && yarn install-sub",
"prebuild": "rimraf ./lib",
"build": "babel src --out-dir lib",
Expand All @@ -33,25 +33,25 @@
"lib"
],
"engines": {
"node": ">=8.0.0"
"node": ">= 10.13.0"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-plugin-add-module-exports": "^1.0.2",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"eslint-config-webpack": "^1.2.5",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.0.1",
"husky": "^2.2.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.6",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"npm-run-all": "^4.1.5",
"prettier": "^1.17.0",
"rimraf": "^2.6.3"
"prettier": "^2.2.1",
"rimraf": "^3.0.2"
}
}
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
printWidth: 80,
useTabs: true,
tabWidth: 2
tabWidth: 2,
};
29 changes: 19 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
import CleanCSS from "clean-css";
import { getOptions } from "loader-utils";

export default function cleanCssLoader(css, map) {
const options = this.options ? this.options.module : false;
const query = getOptions(this);
const cleanCssOptions =
query ||
(options
? options.cleancss || options["clean-css"] || options.CleanCSS
: false) ||
{};
function getCleanCssOptions({ query, options }) {
if (query && Object.keys(query).length > 0) {
return query;
}

const legacyOptionsSyntax =
options && (options.cleancss || options["clean-css"] || options.CleanCSS);

return legacyOptionsSyntax || {};
}

function cleanCssLoader(css, map) {
const callback = this.async();
const cleanCssOptions = getCleanCssOptions({
query: getOptions(this),
options: this.options ? this.options.module : false,
});

return new CleanCSS(cleanCssOptions).minify(css, map, (err, minified) => {
if (err) {
return callback(err[0]);
}

if (!cleanCssOptions.skipWarn && Array.isArray(minified.warnings)) {
minified.warnings.forEach(warning => {
minified.warnings.forEach((warning) => {
this.emitWarning(warning.toString());
});
}

return callback(null, minified.styles, minified.sourceMap);
});
}

export default cleanCssLoader;
5 changes: 3 additions & 2 deletions test/e2e/webpack1/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,9 @@ inherits@2.0.1:
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"

ini@~1.3.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
version "1.3.8"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==

interpret@^0.6.4:
version "0.6.6"
Expand Down
Loading