From 2ff1735200fb8abceae6511123821a3c6e14b531 Mon Sep 17 00:00:00 2001 From: Stas Kurilov Date: Mon, 16 Apr 2018 04:15:37 +0300 Subject: [PATCH 1/2] fix: restore loader object in postcss config context (#355) * fix: restore loader object in postcss config context * test: add testcase which checking webpack object exists in config context --- lib/index.js | 2 ++ test/fixtures/config/context/plugin.js | 15 ++++++++++++++ .../fixtures/config/context/postcss.config.js | 5 +++++ test/options/config.test.js | 20 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 test/fixtures/config/context/plugin.js create mode 100644 test/fixtures/config/context/postcss.config.js diff --git a/lib/index.js b/lib/index.js index d876c069..5afceeef 100644 --- a/lib/index.js +++ b/lib/index.js @@ -90,6 +90,8 @@ module.exports = function loader (css, map, meta) { } } + rc.ctx.webpack = this; + return postcssrc(rc.ctx, rc.path, { argv: false }) }).then((config) => { if (!config) config = {} diff --git a/test/fixtures/config/context/plugin.js b/test/fixtures/config/context/plugin.js new file mode 100644 index 00000000..027eb431 --- /dev/null +++ b/test/fixtures/config/context/plugin.js @@ -0,0 +1,15 @@ +'use strict' + +const postcss = require('postcss') + +// This plugin creates asset file in webpack compilation +module.exports = postcss.plugin('plugin', (ctx) => { + ctx.webpack._compilation.assets['asset.txt'] = { + source() { + return '123'; + }, + size() { + return 0; + } + } +}) diff --git a/test/fixtures/config/context/postcss.config.js b/test/fixtures/config/context/postcss.config.js new file mode 100644 index 00000000..4ba08736 --- /dev/null +++ b/test/fixtures/config/context/postcss.config.js @@ -0,0 +1,5 @@ +module.exports = (ctx) => ({ + plugins: [ + require('./plugin')(ctx) + ] +}) diff --git a/test/options/config.test.js b/test/options/config.test.js index 78135158..cc98c00c 100644 --- a/test/options/config.test.js +++ b/test/options/config.test.js @@ -75,4 +75,24 @@ describe('Options', () => { expect(src).toMatchSnapshot() }) }) + + test('Pass loader object to config context', () => { + const config = { + loader: { + options: { + config: { + path: 'test/fixtures/config/context/postcss.config.js' + } + } + } + } + + return webpack('css/index.js', config).then((stats) => { + const assets = stats.compilation.assets; + const expectedAssetName = 'asset.txt'; + + expect(expectedAssetName in assets).toBeTruthy(); + expect(assets[expectedAssetName].source()).toBe('123'); + }) + }) }) From 2484275a616e218dea6cd49db2f278a373366dda Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Sun, 15 Apr 2018 21:17:52 -0400 Subject: [PATCH 2/2] chore(release): 2.1.4 --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc2b0b78..e9a70773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ 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.1.4](https://github.com/postcss/postcss-loader/compare/v2.1.3...v2.1.4) (2018-04-16) + + +### Bug Fixes + +* restore loader object in postcss config context ([#355](https://github.com/postcss/postcss-loader/issues/355)) ([2ff1735](https://github.com/postcss/postcss-loader/commit/2ff1735)) + + + ## [2.1.3](https://github.com/postcss/postcss-loader/compare/v2.1.2...v2.1.3) (2018-03-20) diff --git a/package.json b/package.json index 338b84ad..719206e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-loader", - "version": "2.1.3", + "version": "2.1.4", "description": "PostCSS loader for webpack", "main": "lib/index.js", "engines": { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy