From df0226bce71a0ac77d9a96d91c9f476a15c55416 Mon Sep 17 00:00:00 2001 From: Nikita Balabaev Date: Wed, 10 May 2017 09:44:02 +0700 Subject: [PATCH 1/5] docs(README): add missing comma (#225) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1def7928..8e0e79c3 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ within the CSS directly as an annotation comment. **webpack.config.js** ```js { - loader: 'postcss-loader' + loader: 'postcss-loader', options: { sourceMap: 'inline' } From 396386025fb7381ced6d046f5b1f947b463055f9 Mon Sep 17 00:00:00 2001 From: Ali Bosworth Date: Tue, 9 May 2017 22:46:18 -0400 Subject: [PATCH 2/5] docs(README): add missing comma (#223) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e0e79c3..e540519c 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ module.exports = { test: /\.css$/, use: [ 'style-loader', - { loader: 'css-loader' options: { importLoaders: 1 } }, + { loader: 'css-loader', options: { importLoaders: 1 } }, 'postcss-loader' ] } From 4f20c9971e823914e80c0b9f6337baee9e7250fc Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Wed, 10 May 2017 10:20:48 +0200 Subject: [PATCH 3/5] fix(index): update validation schema, better warning message --- lib/index.js | 9 ++++----- lib/options.json | 9 +++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6fbf9869..df22b8c4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,7 +5,7 @@ const path = require('path') const loaderUtils = require('loader-utils') const parseOptions = require('./options') -const validateOptions = require('schema-utils') // eslint-disable-line +const validateOptions = require('schema-utils') const postcss = require('postcss') const postcssrc = require('postcss-load-config') @@ -45,8 +45,7 @@ module.exports = function loader (css, map) { const options = loaderUtils.getOptions(this) || {} - // TODO - // validateOptions('./node_modules/postcss-loader/lib/options.json', options, 'PostCSS Loader') + validateOptions(require('./options.json'), options, 'PostCSS Loader') const rc = { path: '', @@ -75,7 +74,7 @@ module.exports = function loader (css, map) { const length = Object.keys(options).length // TODO - // Deuglify + // Refactor if (!options.config && !sourceMap && length) { return parseOptions.call(this, options) } else if (options.config && !sourceMap && length > 1) { @@ -128,7 +127,7 @@ module.exports = function loader (css, map) { } if (!sourceMap && map) { - this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set, this way the loader will discard the source map enterily for performance reasons, see https://github.com/postcss/postcss-loader#sourcemap for more info on the subject\n\n`) + this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set.\nIn this case the loader will discard the source map enterily for performance reasons.\nSee https://github.com/postcss/postcss-loader#sourcemap for more information.\n\n`) } if (sourceMap && typeof map === 'string') map = JSON.parse(map) diff --git a/lib/options.json b/lib/options.json index 29d12972..cd865de1 100644 --- a/lib/options.json +++ b/lib/options.json @@ -13,6 +13,9 @@ }, "additionalProperties": false }, + "exec": { + "type": "boolean" + }, "parser": { "type": "string" }, @@ -24,12 +27,6 @@ }, "sourceMap": { "type": [ "string", "boolean" ] - }, - "exec": { - "type": "boolean" - }, - "rewrite": { - "type": "boolean" } }, "additionalProperties": true From faaeee416f3750381cc58f6e7df2b359d7bd872e Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Wed, 10 May 2017 10:26:13 +0200 Subject: [PATCH 4/5] fix(index): `postcss.config.js` not resolved correctly (`options.config`) --- lib/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index df22b8c4..a90b3074 100644 --- a/lib/index.js +++ b/lib/index.js @@ -48,24 +48,25 @@ module.exports = function loader (css, map) { validateOptions(require('./options.json'), options, 'PostCSS Loader') const rc = { - path: '', + path: path.dirname(file), ctx: { file: { extname: path.extname(file), dirname: path.dirname(file), basename: path.basename(file) - } + }, + options: {} } } if (options.config) { - options.config.path - ? rc.path = path.resolve(options.config.path) - : rc.path = path.dirname(file) + if (options.config.path) { + rc.path = path.resolve(options.config.path) + } - options.config.ctx - ? rc.ctx.options = options.config.ctx - : rc.ctx.options = {} + if (options.config.ctx) { + rc.ctx.options = options.config.ctx + } } const sourceMap = options.sourceMap From cc6544ed89c43e12cf225a4853f1d56febe13bd2 Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Wed, 10 May 2017 11:05:53 +0200 Subject: [PATCH 5/5] chore(release): 2.0.4 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d33bb5b..32d83f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.0.4](https://github.com/postcss/postcss-loader/compare/v2.0.3...v2.0.4) (2017-05-10) + + +### Bug Fixes + +* **index:** `postcss.config.js` not resolved correctly (`options.config`) ([faaeee4](https://github.com/postcss/postcss-loader/commit/faaeee4)) +* **index:** update validation schema, better warning message ([4f20c99](https://github.com/postcss/postcss-loader/commit/4f20c99)) + + + ## [2.0.3](https://github.com/postcss/postcss-loader/compare/v2.0.2...v2.0.3) (2017-05-09) diff --git a/package.json b/package.json index ceebb107..e4d006a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-loader", - "version": "2.0.3", + "version": "2.0.4", "description": "PostCSS loader for webpack", "main": "lib/index.js", "engines": {