{"action":"created","issue":{"url":"https://api.github.com/repos/zeit/next-plugins/issues/21","repository_url":"https://api.github.com/repos/zeit/next-plugins","labels_url":"https://api.github.com/repos/zeit/next-plugins/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/zeit/next-plugins/issues/21/comments","events_url":"https://api.github.com/repos/zeit/next-plugins/issues/21/events","html_url":"https://github.com/zeit/next-plugins/issues/21","id":295757472,"number":21,"title":".next/static/styles.css only has one page style","user":{"login":"davidqhr","id":5846959,"avatar_url":"https://avatars3.githubusercontent.com/u/5846959?v=4","gravatar_id":"","url":"https://api.github.com/users/davidqhr","html_url":"https://github.com/davidqhr","followers_url":"https://api.github.com/users/davidqhr/followers","following_url":"https://api.github.com/users/davidqhr/following{/other_user}","gists_url":"https://api.github.com/users/davidqhr/gists{/gist_id}","starred_url":"https://api.github.com/users/davidqhr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidqhr/subscriptions","organizations_url":"https://api.github.com/users/davidqhr/orgs","repos_url":"https://api.github.com/users/davidqhr/repos","events_url":"https://api.github.com/users/davidqhr/events{/privacy}","received_events_url":"https://api.github.com/users/davidqhr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-09T05:15:54Z","updated_at":"2018-02-09T15:21:29Z","closed_at":null,"author_association":"NONE","body":"I have multi pages. Each page has its own styles files included.\r\n\r\n```javascript\r\n// pages/a.js\r\nimport \"../styles/pageA.scss\"\r\n```\r\n\r\n```javascript\r\n// pages/b.js\r\nimport \"../styles/pageB.scss\"\r\n```\r\n\r\nAfter building in production mode.\r\nI got one file which stored at .next/static/style.css\r\n\r\nAll style of pageA.scss is missing. If I remove the `import \"../styles/pageB.scss\"` statement, then build. I can see the style of page a.\r\n\r\nIs the styles.css generated multi times, and the second replace the first one. So the style of page a is missing in the end."},"comment":{"url":"https://api.github.com/repos/zeit/next-plugins/issues/comments/364463519","html_url":"https://github.com/zeit/next-plugins/issues/21#issuecomment-364463519","issue_url":"https://api.github.com/repos/zeit/next-plugins/issues/21","id":364463519,"user":{"login":"plag","id":3114398,"avatar_url":"https://avatars1.githubusercontent.com/u/3114398?v=4","gravatar_id":"","url":"https://api.github.com/users/plag","html_url":"https://github.com/plag","followers_url":"https://api.github.com/users/plag/followers","following_url":"https://api.github.com/users/plag/following{/other_user}","gists_url":"https://api.github.com/users/plag/gists{/gist_id}","starred_url":"https://api.github.com/users/plag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plag/subscriptions","organizations_url":"https://api.github.com/users/plag/orgs","repos_url":"https://api.github.com/users/plag/repos","events_url":"https://api.github.com/users/plag/events{/privacy}","received_events_url":"https://api.github.com/users/plag/received_events","type":"User","site_admin":false},"created_at":"2018-02-09T15:21:29Z","updated_at":"2018-02-09T15:21:29Z","author_association":"NONE","body":"Just make fast dirty fix for production builds:\r\n\r\n`next.config.js`\r\n\r\n```\r\n...\r\n    config.plugins.push(\r\n      new MergeFilesPlugin({\r\n        filename: 'static/style.css',\r\n        test: /style\\.css/,\r\n        deleteSourceFiles: true,\r\n      }),\r\n    );\r\n...\r\n```\r\n\r\n\r\n`optimize.js`\r\n```\r\nconst fs = require('fs');\r\nconst postcss = require('postcss');\r\nconst cssnano = require('cssnano');\r\n\r\nconst src = process.argv[2];\r\nconst dst = process.argv[3];\r\n\r\nfs.readFile(src, (err, css) => {\r\n  postcss([cssnano])\r\n    .process(css, { from: src, to: dst })\r\n    .then(result => {\r\n        fs.writeFile(dst, result.css);\r\n        if (result.map) fs.writeFile(dst.replace(/\\.css$/, '.map.css'), result.map);\r\n    });\r\n});\r\n``` \r\n\r\n`package.json`\r\n```\r\n...\r\nscripts: {\r\n   ...\r\n   \"build\": \"next build && node optimize-css.js .next/static/style.css .next/static/styles.css\",\r\n   ...\r\n}\r\n...\r\n```\r\n\r\n`Layout.js`\r\n```\r\n...\r\n   <Head>\r\n   ...\r\n      {\r\n        isProduction && <link rel=\"stylesheet\" href=\"/_next/static/styles.css\" />\r\n      }\r\n   ...\r\n   </Head>\r\n...\r\n```\r\n\r\nand finally\r\n\r\n`yarn build`\r\n`yarn start`\r\n\r\n:-) of course, i'll fix it after get right config, but good for begin. My old config with deprecated rewrited configs + one big single file was more horrendous)\r\n\r\n"}}
{"actor":{"display_login":"plag"}}