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