-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(postcss-plugin): Add support for postcss-loader 2.x (#7)
- Loading branch information
Showing
16 changed files
with
256 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
language: node_js | ||
node_js: | ||
- "4" | ||
- "5" | ||
- "6" | ||
script: | ||
- npm test | ||
- npm run example:default | ||
after_success: | ||
- './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' | ||
- './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
|
||
environment: | ||
matrix: | ||
- nodejs_version: 4 | ||
- nodejs_version: 5 | ||
- nodejs_version: 6 | ||
|
||
version: "{build}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,80 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
|
||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
|
||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
|
||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
|
||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
|
||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
|
||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
|
||
|
||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
|
||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
|
||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
|
||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
__webpack_require__(1); | ||
__webpack_require__(1); | ||
|
||
|
||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
|
||
// removed by extract-text-webpack-plugin | ||
// removed by extract-text-webpack-plugin | ||
|
||
/***/ }) | ||
/******/ ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
'use strict'; | ||
var _ = require('lodash'); | ||
let _ = require('lodash'); | ||
let assert = require('assert'); | ||
|
||
function IconfontWebpackPlugin (options) { | ||
module.exports = function IconfontWebpackPlugin (userOptions) { | ||
// Default options | ||
this.options = _.extend({ | ||
fontNamePrefix: '' | ||
}, options); | ||
} | ||
const options = _.extend({ | ||
|
||
IconfontWebpackPlugin.prototype.apply = function (compiler) { | ||
compiler.plugin('compilation', (compilation) => | ||
compilation.plugin('postcss-loader-before-processing', | ||
(plugins) => (plugins || []).concat( | ||
require('./lib/postcss-plugin')({ | ||
compiler: compiler, | ||
pluginOptions: this.options | ||
}) | ||
) | ||
) | ||
// allows to prefix the font name to prevent collisions | ||
fontNamePrefix: '', | ||
|
||
// resolve function to translate webpack urls into absolute filepaths | ||
// e.g. url('demo.svg') -> '/Users/me/project-x/demo.svg' | ||
// usually you should pass on the postcss loader | ||
// https://webpack.js.org/api/loaders/#this-resolve | ||
resolve: undefined | ||
|
||
}, userOptions); | ||
|
||
// Verify resolve function | ||
assert(typeof options.resolve === 'function', | ||
'Please pass a resolve function to the IconFontWebpackPlugin.\n' + | ||
'For example: \n' + | ||
'{\n' + | ||
' loader: \'postcss-loader\',\n' + | ||
' options: {\n' + | ||
' plugins: (loader) => [\n' + | ||
' require(\'iconfont-webpack-plugin\')({ resolve: loader.resolve }), \n\n' | ||
); | ||
}; | ||
|
||
module.exports = IconfontWebpackPlugin; | ||
// Call postcss plugin | ||
return require('./lib/postcss-plugin')(options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.