Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,207 @@
# Change Log
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.0.8"></a>
## [2.0.8](https://github.com/postcss/postcss-loader/compare/v2.0.6...v2.0.8) (2017-10-14)
### Bug Fixes
* **lib/options:** handle `{Object}` return (`options.plugins`) ([#301](https://github.com/postcss/postcss-loader/issues/301)) ([df010a7](https://github.com/postcss/postcss-loader/commit/df010a7))
* **schema:** allow to pass an `{Object}` (`options.syntax/options.stringifier`) ([#300](https://github.com/postcss/postcss-loader/issues/300)) ([58e9996](https://github.com/postcss/postcss-loader/commit/58e9996))
<a name="2.0.7"></a>
## [2.0.7](https://github.com/postcss/postcss-loader/compare/v2.0.6...v2.0.7) (2017-10-10)
### Bug Fixes
* sanitizing `from` and `to` options (`postcss.config.js`) ([#260](https://github.com/postcss/postcss-loader/issues/260)) ([753dea7](https://github.com/postcss/postcss-loader/commit/753dea7))
* **index:** runaway promise ([#269](https://github.com/postcss/postcss-loader/issues/269)) ([8df20ce](https://github.com/postcss/postcss-loader/commit/8df20ce))
<a name="2.0.6"></a>
## [2.0.6](https://github.com/postcss/postcss-loader/compare/v2.0.5...v2.0.6) (2017-06-14)
### Bug Fixes
* allow to pass an `{Object}` (`options.parser`) ([#257](https://github.com/postcss/postcss-loader/issues/257)) ([4974607](https://github.com/postcss/postcss-loader/commit/4974607))
* misspelling in warnings ([#237](https://github.com/postcss/postcss-loader/issues/237)) ([adcbb2e](https://github.com/postcss/postcss-loader/commit/adcbb2e))
* **index:** simplify config loading behaviour ([#259](https://github.com/postcss/postcss-loader/issues/259)) ([b313478](https://github.com/postcss/postcss-loader/commit/b313478))
<a name="2.0.5"></a>
## [2.0.5](https://github.com/postcss/postcss-loader/compare/v2.0.4...v2.0.5) (2017-05-10)
### Bug Fixes
* regression with `options.plugins` `{Function}` (`webpack.config.js`) (#229) ([dca52a9](https://github.com/postcss/postcss-loader/commit/dca52a9))
<a name="2.0.4"></a>
## [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))
<a name="2.0.3"></a>
## [2.0.3](https://github.com/postcss/postcss-loader/compare/v2.0.2...v2.0.3) (2017-05-09)
### Bug Fixes
* **index:** don't fail on 'sourceMap: false' && emit a warning instead, when previous map found (`options.sourceMap`) ([159b66a](https://github.com/postcss/postcss-loader/commit/159b66a))
<a name="2.0.2"></a>
## [2.0.2](https://github.com/postcss/postcss-loader/compare/v2.0.1...v2.0.2) (2017-05-09)
### Bug Fixes
* **index:** 'No PostCSS Config found' (`options.config`) (#215) ([e764761](https://github.com/postcss/postcss-loader/commit/e764761))
<a name="2.0.1"></a>
## [2.0.1](https://github.com/postcss/postcss-loader/compare/v2.0.0...v2.0.1) (2017-05-08)
### Bug Fixes
* **index:** 'Cannot create property `prev` on boolean `false`' (`options.sourceMap`) ([c4f0064](https://github.com/postcss/postcss-loader/commit/c4f0064))
<a name="2.0.0"></a>
# [2.0.0](https://github.com/postcss/postcss-loader/compare/1.2.2...v2.0.0) (2017-05-08)
### Features
* **index:** add ctx, ctx.file, ctx.options ([0dceb2c](https://github.com/postcss/postcss-loader/commit/0dceb2c))
* **index:** add options validation ([2b76df8](https://github.com/postcss/postcss-loader/commit/2b76df8))
## 1.3.3
* Remove `postcss-loader-before-processing` warning (by Michael Ciniawsky).
## 1.3.2
* Fix deprecated warning (by Xiaoyu Zhai).
## 1.3.1
* Fix conflict with CLI `--config` argument (by EGOIST).
## 1.3
* Allow object in syntax options, not only path for require (by Jeff Escalante).
## 1.2.2
* Watch `postcss.config.js` for changes (by Michael Ciniawsky).
## 1.2.1
* Fix relative `config` parameter resolving (by Simen Bekkhus).
## 1.2
* Add `config` parameter (by sainthkh).
## 1.1.1
* Fix `this` in options function (by Jeff Escalante).
## 1.1
* PostCSS common config could be placed to subdirs.
* Add webpack instance to PostCSS common config context.
## 1.0
* Add common PostCSS config support (by Mateusz Derks).
* Add Webpack 2 support with `plugins` query option (by Izaak Schroeder).
* Add `dependency` message support.
* Rewrite docs (by Michael Ciniawsky).
## 0.13
* Add `exec` parameter (by Neal Granger).
## 0.12
* Add CSS syntax highlight to syntax error code frame.
## 0.11.1
* Fix Promise API (by Daniel Haus).
## 0.11
* Add `postcss-loader-before-processing` webpack event (by Jan Nicklas).
## 0.10.1
* Better syntax error message (by Andrey Popp).
## 0.10.0
* Add `sourceMap` parameter to force inline maps (by 雪狼).
## 0.9.1
* Fix plugin in simple array config.
## 0.9
* Allow to pass syntax, parser or stringifier as function (by Jeff Escalante).
## 0.8.2
* Fix source map support (by Andrew Bradley).
## 0.8.1
* Fix resource path.
## 0.8
* Add postcss-js support (by Simon Degraeve).
## 0.7
* Added argument with webpack instance to plugins callback (by Maxime Thirouin).
## 0.6
* Use PostCSS 5.0.
* Remove `safe` parameter. Use Safe Parser.
* Add `syntax`, `parser` and `stringifier` parameters.
## 0.5.1
* Fix string source map support (by Jan Nicklas).
## 0.5.0
* Set plugins by function for hot reload support (by Stefano Brilli).
## 0.4.4
* Fix error on empty PostCSS config.
## 0.4.3
* Better check for `CssSyntaxError`.
## 0.4.2
* Fixed invalid sourcemap exception (by Richard Willis).
## 0.4.1
* Use only Promise API to catch PostCSS errors.
## 0.4
* Add PostCSS asynchronous API support.
* Fix source map support (by Richard Willis).
* Add warnings API support.
* Better output for CSS syntax errors.
## 0.3
* Use PostCSS 4.0.
## 0.2
* Use PostCSS 3.0.
## 0.1
* Initial release.

View File

@@ -0,0 +1,20 @@
License (MIT)
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,468 @@
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
<div align="center">
<img width="180" height="180" hspace="10"
alt="PostCSS Logo"
src="http://postcss.github.io/postcss/logo.svg">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200" hspace="10"
src="https://cdn.rawgit.com/webpack/media/e7485eb2/logo/icon.svg">
</a>
<div align="center">
<a href="https://evilmartians.com/?utm_source=postcss">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54" vspace="10">
</a>
</div>
<h1>PostCSS Loader</h1>
<p>Loader for <a href="http://webpack.js.org/">webpack</a> to process CSS with <a href="http://postcss.org/">PostCSS</a></p>
</div>
<h2 align="center">Install</h2>
```bash
npm i -D postcss-loader
```
<h2 align="center">Usage</h2>
### `Configuration`
**postcss.config.js**
```js
module.exports = {
parser: 'sugarss',
plugins: {
'postcss-import': {},
'postcss-cssnext': {},
'cssnano': {}
}
}
```
You can read more about common PostCSS Config [here](https://github.com/michael-ciniawsky/postcss-load-config).
### `Config Cascade`
You can use different `postcss.config.js` files in different directories.
Config lookup starts from `path.dirname(file)` and walks the file tree upwards until a config file is found.
```
| components
| | component
| | | index.js
| | | index.png
| | | style.css (1)
| | | postcss.config.js (1)
| | component
| | | index.js
| | | image.png
| | | style.css (2)
|
| postcss.config.js (1 && 2 (recommended))
| webpack.config.js
|
| package.json
```
After setting up your `postcss.config.js`, add `postcss-loader` to your `webpack.config.js`. You can use it standalone or in conjunction with `css-loader` (recommended). Use it **after** `css-loader` and `style-loader`, but **before** other preprocessor loaders like e.g `sass|less|stylus-loader`, if you use any.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'postcss-loader' ]
}
]
}
}
```
> ⚠️ When `postcss-loader` is used standalone (without `css-loader`) don't use `@import` in your CSS, since this can lead to quite bloated bundles
**webpack.config.js (recommended)**
```js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
}
]
}
}
```
<h2 align="center">Options</h2>
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`exec`](#exec)|`{Boolean}`|`undefined`|Enable PostCSS Parser support in `CSS-in-JS`|
|[`parser`](#syntaxes)|`{String\|Object}`|`undefined`|Set PostCSS Parser|
|[`syntax`](#syntaxes)|`{String\|Object}`|`undefined`|Set PostCSS Syntax|
|[`stringifier`](#syntaxes)|`{String\|Object}`|`undefined`|Set PostCSS Stringifier|
|[`config`](#config)|`{Object}`|`undefined`|Set `postcss.config.js` config path && `ctx`|
|[`plugins`](#plugins)|`{Array\|Function}`|`[]`|Set PostCSS Plugins|
|[`sourceMap`](#sourceMap)|`{String\|Boolean}`|`false`|Enable Source Maps|
### `Exec`
If you use JS styles without the [`postcss-js`][postcss-js] parser, add the `exec` option.
```js
{
test: /\.style.js$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: { parser: 'sugarss', exec: true } }
]
}
```
### `Config`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`path`](#path)|`{String}`|`undefined`|PostCSS Config Path|
|[`context`](#context)|`{Object}`|`undefined`|PostCSS Config Context|
#### `Path`
You can manually specify the path to search for your config (`postcss.config.js`) with the `config.path` option. This is needed if you store your config in a separate e.g `./config || ./.config` folder.
> ⚠️ Otherwise it is **unnecessary** to set this option and is **not** recommended
**webpack.config.js**
```js
{
loader: 'postcss-loader',
options: {
config: {
path: 'path/to/postcss.config.js'
}
}
}
```
#### `Context (ctx)`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|`env`|`{String}`|`'development'`|`process.env.NODE_ENV`|
|`file`|`{Object}`|`loader.resourcePath`|`extname`, `dirname`, `basename`|
|`options`|`{Object}`|`{}`|Options|
`postcss-loader` exposes context `ctx` to the config file, making your `postcss.config.js` dynamic, so can use it to do some real magic ✨
**postcss.config.js**
```js
module.exports = ({ file, options, env }) => ({
parser: file.extname === '.sss' ? 'sugarss' : false,
plugins: {
'postcss-import': { root: file.dirname },
'postcss-cssnext': options.cssnext ? options.cssnext : false,
'autoprefixer': env == 'production' ? options.autoprefixer : false,
'cssnano': env === 'production' ? options.cssnano : false
}
})
```
**webpack.config.js**
```js
{
loader: 'postcss-loader',
options: {
config: {
ctx: {
cssnext: {...options},
cssnano: {...options},
autoprefixer: {...options}
}
}
}
}
```
### `Plugins`
**webpack.config.js**
```js
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: (loader) => [
require('postcss-import')({ root: loader.resourcePath }),
require('postcss-cssnext')(),
require('autoprefixer')(),
require('cssnano')()
]
}
}
```
> ⚠️ webpack requires an identifier (`ident`) in `options` when `{Function}/require` is used (Complex Options). The `ident` can be freely named as long as it is unique. It's recommended to name it (`ident: 'postcss'`)
### `Syntaxes`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`parser`](#parser)|`{String\|Function}`|`undefined`|Custom PostCSS Parser|
|[`syntax`](#syntax)|`{String\|Function}`|`undefined`|Custom PostCSS Syntax|
|[`stringifier`](#stringifier)|`{String\|Function}`|`undefined`|Custom PostCSS Stringifier|
#### `Parser`
**webpack.config.js**
```js
{
test: /\.sss$/,
use: [
...,
{ loader: 'postcss-loader', options: { parser: 'sugarss' } }
]
}
```
#### `Syntax`
**webpack.config.js**
```js
{
test: /\.css$/,
use: [
...,
{ loader: 'postcss-loader', options: { syntax: 'sugarss' } }
]
}
```
#### `Stringifier`
**webpack.config.js**
```js
{
test: /\.css$/,
use: [
...,
{ loader: 'postcss-loader', options: { stringifier: 'midas' } }
]
}
```
### `SourceMap`
Enables source map support, `postcss-loader` will use the previous source map given by other loaders and update it accordingly, if no previous loader is applied before `postcss-loader`, the loader will generate a source map for you.
> :warning: If a previous loader like e.g `sass-loader` is applied and it's `sourceMap` option is set, but the `sourceMap` option in `postcss-loader` is omitted, previous source maps will be discarded by `postcss-loader` **entirely**.
**webpack.config.js**
```js
{
test: /\.css/,
use: [
{ loader: 'style-loader', options: { sourceMap: true } },
{ loader: 'css-loader', options: { sourceMap: true } },
{ loader: 'postcss-loader', options: { sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } }
]
}
```
#### `'inline'`
You can set the `sourceMap: 'inline'` option to inline the source map
within the CSS directly as an annotation comment.
**webpack.config.js**
```js
{
loader: 'postcss-loader',
options: {
sourceMap: 'inline'
}
}
```
```css
.class { color: red; }
/*# sourceMappingURL=data:application/json;base64, ... */
```
<h2 align="center">Examples</h2>
### `Stylelint`
**webpack.config.js**
```js
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [
require('postcss-import')(),
require('stylelint')(),
...,
]
}
}
]
}
```
### `CSS Modules`
This loader [cannot be used] with [CSS Modules] out of the box due
to the way `css-loader` processes file imports. To make them work properly,
either add the css-loaders [`importLoaders`] option.
**webpack.config.js**
```js
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { modules: true, importLoaders: 1 } },
'postcss-loader'
]
}
```
or use [postcss-modules] instead of `css-loader`.
[`importLoaders`]: https://github.com/webpack-contrib/css-loader#importing-and-chained-loaders
[cannot be used]: https://github.com/webpack/css-loader/issues/137
[CSS Modules]: https://github.com/webpack/css-loader#css-modules
[postcss-modules]: https://github.com/outpunk/postcss-modules
### `CSS-in-JS`
If you want to process styles written in JavaScript, use the [postcss-js] parser.
[postcss-js]: https://github.com/postcss/postcss-js
```js
{
test: /\.style.js$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 2 } },
{ loader: 'postcss-loader', options: { parser: 'postcss-js' } },
'babel-loader'
]
}
```
As result you will be able to write styles in the following way
```js
import colors from './styles/colors'
export default {
'.menu': {
color: colors.main,
height: 25,
'&_link': {
color: 'white'
}
}
}
```
> :warning: If you are using Babel you need to do the following in order for the setup to work
> 1. Add [babel-plugin-add-module-exports] to your configuration
> 2. You need to have only one **default** export per style module
[babel-plugin-add-module-exports]: https://github.com/59naga/babel-plugin-add-module-exports
### [Extract CSS][ExtractPlugin]
[ExtractPlugin]: https://github.com/webpack-contrib/extract-text-webpack-plugin
**webpack.config.js**
```js
const ExtractTextPlugin = require('extract-text-webpack-plugin')
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
})
}
]
},
plugins: [
new ExtractTextPlugin('[name].css')
]
}
```
<h2 align="center">Maintainers</h2>
<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/michael-ciniawsky">
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">
</br>
Michael Ciniawsky
</a>
</td>
<td align="center">
<a href="https://github.com/evilebottnawi">
<img width="150" height="150" src="https://github.com/evilebottnawi.png?v=3&s=150">
</br>
Alexander Krasnoyarov
</a>
</td>
</tr>
<tbody>
</table>
[npm]: https://img.shields.io/npm/v/postcss-loader.svg
[npm-url]: https://npmjs.com/package/postcss-loader
[node]: https://img.shields.io/node/v/postcss-loader.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/postcss/postcss-loader.svg
[deps-url]: https://david-dm.org/postcss/postcss-loader
[tests]: http://img.shields.io/travis/postcss/postcss-loader.svg
[tests-url]: https://travis-ci.org/postcss/postcss-loader
[cover]: https://coveralls.io/repos/github/postcss/postcss-loader/badge.svg
[cover-url]: https://coveralls.io/github/postcss/postcss-loader
[chat]: https://badges.gitter.im/postcss/postcss.svg
[chat-url]: https://gitter.im/postcss/postcss

View File

@@ -0,0 +1,17 @@
'use strict'
class SyntaxError extends Error {
constructor (err) {
super(err)
this.name = 'Syntax Error'
this.message = ''
this.message += `${this.name} \n\n(${err.line}:${err.column}) ${err.reason}`
this.message += `\n\n${err.showSourceCode()}\n`
this.stack = false
}
}
module.exports = SyntaxError

View File

@@ -0,0 +1,187 @@
'use strict'
const path = require('path')
const loaderUtils = require('loader-utils')
const parseOptions = require('./options')
const validateOptions = require('schema-utils')
const postcss = require('postcss')
const postcssrc = require('postcss-load-config')
const SyntaxError = require('./Error')
/**
* PostCSS Loader
*
* > Loads && processes CSS with [PostCSS](https://github.com/postcss/postcss)
*
* @author Andrey Sitnik (@ai) <andrey@sitnik.ru>
*
* @license MIT
* @version 2.0.0
*
* @requires path
*
* @requires loader-utils
* @requires schema-utils
*
* @requires postcss
* @requires postcss-load-config
*
* @requires Error
*
* @method loader
*
* @param {String} css Source
* @param {Object} map Source Map
*
* @return {cb} cb Result
*/
module.exports = function loader (css, map) {
const options = loaderUtils.getOptions(this) || {}
validateOptions(require('./options.json'), options, 'PostCSS Loader')
const cb = this.async()
const file = this.resourcePath
const sourceMap = options.sourceMap
Promise.resolve().then(() => {
const length = Object.keys(options)
.filter((option) => {
// if (option === 'exec') return
if (option === 'config') return
if (option === 'sourceMap') return
return option
})
.length
if (length) {
return parseOptions.call(this, options)
}
const rc = {
path: path.dirname(file),
ctx: {
file: {
extname: path.extname(file),
dirname: path.dirname(file),
basename: path.basename(file)
},
options: {}
}
}
if (options.config) {
if (options.config.path) {
rc.path = path.resolve(options.config.path)
}
if (options.config.ctx) {
rc.ctx.options = options.config.ctx
}
}
return postcssrc(rc.ctx, rc.path, { argv: false })
}).then((config) => {
if (!config) config = {}
if (config.file) this.addDependency(config.file)
// Disable override `to` option from `postcss.config.js`
if (config.options.to) delete config.options.to
// Disable override `from` option from `postcss.config.js`
if (config.options.from) delete config.options.from
let plugins = config.plugins || []
let options = Object.assign({
to: file,
from: file,
map: sourceMap
? sourceMap === 'inline'
? { inline: true, annotation: false }
: { inline: false, annotation: false }
: false
}, config.options)
// Loader Exec (Deprecated)
// https://webpack.js.org/api/loaders/#deprecated-context-properties
if (options.parser === 'postcss-js') {
css = this.exec(css, this.resource)
}
if (typeof options.parser === 'string') {
options.parser = require(options.parser)
}
if (typeof options.syntax === 'string') {
options.syntax = require(options.syntax)
}
if (typeof options.stringifier === 'string') {
options.stringifier = require(options.stringifier)
}
// Loader API Exec (Deprecated)
// https://webpack.js.org/api/loaders/#deprecated-context-properties
if (config.exec) {
css = this.exec(css, this.resource)
}
if (!sourceMap && map) {
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 entirely 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)
if (sourceMap && map) options.map.prev = map
return postcss(plugins)
.process(css, options)
.then((result) => {
result.warnings().forEach((msg) => this.emitWarning(msg.toString()))
result.messages.forEach((msg) => {
if (msg.type === 'dependency') this.addDependency(msg.file)
})
css = result.css
map = result.map ? result.map.toJSON() : null
if (map) {
map.file = path.resolve(map.file)
map.sources = map.sources.map((src) => path.resolve(src))
}
if (this.loaderIndex === 0) {
/**
* @memberof loader
* @callback cb
*
* @param {Object} null Error
* @param {String} result Result (JS Module)
* @param {Object} map Source Map
*/
cb(null, `module.exports = ${JSON.stringify(css)}`, map)
return null
}
/**
* @memberof loader
* @callback cb
*
* @param {Object} null Error
* @param {String} css Result (Raw Module)
* @param {Object} map Source Map
*/
cb(null, css, map)
return null
})
}).catch((err) => {
return err.name === 'CssSyntaxError' ? cb(new SyntaxError(err)) : cb(err)
})
}

View File

@@ -0,0 +1,25 @@
'use strict'
module.exports = function parseOptions (params) {
if (typeof params.plugins === 'function') {
params.plugins = params.plugins.call(this, this)
}
let plugins
if (typeof params.plugins === 'undefined') plugins = []
else if (Array.isArray(params.plugins)) plugins = params.plugins
else plugins = [ params.plugins ]
const options = {}
if (typeof params !== 'undefined') {
options.parser = params.parser
options.syntax = params.syntax
options.stringifier = params.stringifier
}
const exec = params && params.exec
return Promise.resolve({ options: options, plugins: plugins, exec: exec })
}

View File

@@ -0,0 +1,40 @@
{
"type": "object",
"properties": {
"config": {
"type": "object",
"properties": {
"path": {
"type": "string"
},
"ctx": {
"type": "object"
}
},
"additionalProperties": false
},
"exec": {
"type": "boolean"
},
"parser": {
"type": [ "string", "object" ]
},
"syntax": {
"type": [ "string", "object" ]
},
"stringifier": {
"type": [ "string", "object" ]
},
"plugins": {
"anyOf": [
{ "type": "array" },
{ "type": "object" },
{ "instanceof": "Function" }
]
},
"sourceMap": {
"type": [ "string", "boolean" ]
}
},
"additionalProperties": true
}

View File

@@ -0,0 +1,99 @@
{
"_args": [
[
"postcss-loader@2.0.8",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "postcss-loader@2.0.8",
"_id": "postcss-loader@2.0.8",
"_inBundle": false,
"_integrity": "sha512-KtXBiQ/r/WYW8LxTSJK7h8wLqvCMSub/BqmRnud/Mu8RzwflW9cmXxwsMwbn15TNv287Hcufdb3ZSs7xHKnG8Q==",
"_location": "/react-scripts/postcss-loader",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "postcss-loader@2.0.8",
"name": "postcss-loader",
"escapedName": "postcss-loader",
"rawSpec": "2.0.8",
"saveSpec": null,
"fetchSpec": "2.0.8"
},
"_requiredBy": [
"/react-scripts"
],
"_resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-2.0.8.tgz",
"_spec": "2.0.8",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Andrey Sitnik",
"email": "andrey@sitnik.ru"
},
"bugs": {
"url": "https://github.com/postcss/postcss-loader/issues"
},
"dependencies": {
"loader-utils": "^1.1.0",
"postcss": "^6.0.0",
"postcss-load-config": "^1.2.0",
"schema-utils": "^0.3.0"
},
"description": "PostCSS loader for webpack",
"devDependencies": {
"coveralls": "^2.0.0",
"jest": "^21.0.0",
"jsdoc-to-markdown": "^3.0.0",
"memory-fs": "^0.4.0",
"postcss-js": "^1.0.0",
"standard": "^10.0.0",
"standard-version": "^4.0.0",
"sugarss": "^1.0.0",
"webpack": "^3.0.0"
},
"engines": {
"node": ">= 4"
},
"files": [
"lib"
],
"homepage": "https://github.com/postcss/postcss-loader#readme",
"jest": {
"collectCoverageFrom": [
"lib/*.js"
]
},
"keywords": [
"css",
"postcss",
"postcss-runner",
"webpack",
"webpack-loader"
],
"license": "MIT",
"main": "lib/index.js",
"name": "postcss-loader",
"repository": {
"type": "git",
"url": "git+https://github.com/postcss/postcss-loader.git"
},
"scripts": {
"clean": "rm -rf dmd jest* coverage jsdoc-api test/results",
"docs": "jsdoc2md lib/index.js > LOADER.md",
"lint": "standard",
"postdocs": "npm run clean",
"pretest": "npm run clean",
"release": "standard-version",
"test": "jest --verbose --coverage"
},
"standard": {
"env": {
"jest": true
},
"ignore": [
"*.test.js"
]
},
"version": "2.0.8"
}