Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack-contrib/postcss-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.3
Choose a base ref
...
head repository: webpack-contrib/postcss-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.4
Choose a head ref
  • 2 commits
  • 6 files changed
  • 2 contributors

Commits on Apr 16, 2018

  1. 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
    kisenka authored and ai committed Apr 16, 2018

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    2ff1735 View commit details
  2. chore(release): 2.1.4

    ai committed Apr 16, 2018
    Copy the full SHA
    2484275 View commit details
Showing with 53 additions and 1 deletion.
  1. +10 −0 CHANGELOG.md
  2. +2 −0 lib/index.js
  3. +1 −1 package.json
  4. +15 −0 test/fixtures/config/context/plugin.js
  5. +5 −0 test/fixtures/config/context/postcss.config.js
  6. +20 −0 test/options/config.test.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

<a name="2.1.4"></a>
## [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))



<a name="2.1.3"></a>
## [2.1.3](https://github.com/postcss/postcss-loader/compare/v2.1.2...v2.1.3) (2018-03-20)

2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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 = {}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
15 changes: 15 additions & 0 deletions test/fixtures/config/context/plugin.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
})
5 changes: 5 additions & 0 deletions test/fixtures/config/context/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = (ctx) => ({
plugins: [
require('./plugin')(ctx)
]
})
20 changes: 20 additions & 0 deletions test/options/config.test.js
Original file line number Diff line number Diff line change
@@ -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');
})
})
})