{"action":"created","issue":{"url":"https://api.github.com/repos/pirelenito/sagui/issues/31","repository_url":"https://api.github.com/repos/pirelenito/sagui","labels_url":"https://api.github.com/repos/pirelenito/sagui/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/pirelenito/sagui/issues/31/comments","events_url":"https://api.github.com/repos/pirelenito/sagui/issues/31/events","html_url":"https://github.com/pirelenito/sagui/pull/31","id":132559530,"number":31,"title":"Create an internal plugin infrastructure","user":{"login":"pirelenito","id":6001,"avatar_url":"https://avatars.githubusercontent.com/u/6001?v=3","gravatar_id":"","url":"https://api.github.com/users/pirelenito","html_url":"https://github.com/pirelenito","followers_url":"https://api.github.com/users/pirelenito/followers","following_url":"https://api.github.com/users/pirelenito/following{/other_user}","gists_url":"https://api.github.com/users/pirelenito/gists{/gist_id}","starred_url":"https://api.github.com/users/pirelenito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pirelenito/subscriptions","organizations_url":"https://api.github.com/users/pirelenito/orgs","repos_url":"https://api.github.com/users/pirelenito/repos","events_url":"https://api.github.com/users/pirelenito/events{/privacy}","received_events_url":"https://api.github.com/users/pirelenito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-09T22:50:02Z","updated_at":"2016-02-10T12:39:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pirelenito/sagui/pulls/31","html_url":"https://github.com/pirelenito/sagui/pull/31","diff_url":"https://github.com/pirelenito/sagui/pull/31.diff","patch_url":"https://github.com/pirelenito/sagui/pull/31.patch"},"body":"This PR is a WIP to create an internal *plugin infrastructure*. Once it is stable \"enough\" it could be exposed as an API to a project using Sagui.\r\n\r\nThe first internal (build) plugins are:\r\n\r\n- Babel\r\n- CSS Modules\r\n- ESLint\r\n- JSON\r\n- Media: images and fonts\r\n- Pages: support multiple page outputs\r\n- SCSS\r\n\r\nThe internal plugin infrastructure is used to setup the entire Sagui environment, loading user preferences, setting up paths, the test runner (Karma) and the builder (Webpack).\r\n\r\nIt still requires some remaining cleaning work and documentation before it can be merged."},"comment":{"url":"https://api.github.com/repos/pirelenito/sagui/issues/comments/182353815","html_url":"https://github.com/pirelenito/sagui/pull/31#issuecomment-182353815","issue_url":"https://api.github.com/repos/pirelenito/sagui/issues/31","id":182353815,"user":{"login":"pirelenito","id":6001,"avatar_url":"https://avatars.githubusercontent.com/u/6001?v=3","gravatar_id":"","url":"https://api.github.com/users/pirelenito","html_url":"https://github.com/pirelenito","followers_url":"https://api.github.com/users/pirelenito/followers","following_url":"https://api.github.com/users/pirelenito/following{/other_user}","gists_url":"https://api.github.com/users/pirelenito/gists{/gist_id}","starred_url":"https://api.github.com/users/pirelenito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pirelenito/subscriptions","organizations_url":"https://api.github.com/users/pirelenito/orgs","repos_url":"https://api.github.com/users/pirelenito/repos","events_url":"https://api.github.com/users/pirelenito/events{/privacy}","received_events_url":"https://api.github.com/users/pirelenito/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T12:39:25Z","updated_at":"2016-02-10T12:39:25Z","body":"So the idea is that a user can setup Sagui in two different ways:\r\n\r\n### Configuration\r\n\r\nBy creating a file `sagui.config.js` you can leverage the existing plugins by providing some static configuration:\r\n\r\n```js\r\nmodule.exports = {\r\n  pages: ['index', 'demo']\r\n}\r\n```\r\n\r\nThe configuration is **loaded before any plugin is processed**.\r\n\r\n### Extension\r\n\r\nExtension is a much powerful feature, by creating a file `sagui.extension.js`, the user has access to the entire runtime environment of Sagui, allowing extension of pretty much anything (such as webpack configuration). It works exactly like an internal plugin.\r\n\r\nHere is an example of setting up an YAML loader:\r\n\r\n```js\r\nmodule.exports = function (env, merge) {\r\n  const webpackConfig = merge(env.webpackConfig, {\r\n    module: {\r\n      loaders: [\r\n        {\r\n          test: /\\.(yaml)$/,\r\n          loader: 'yaml-loader'\r\n        }\r\n      ]\r\n    }\r\n  })\r\n\r\n  return Object.assign({}, env, { webpackConfig: webpackConfig })\r\n}\r\n```\r\n\r\nIn contrast with configuration, the extension is executed as the **last step in the plugin chain**, allowing the user to overwrite or add any extra configuration."}}