{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/181","repository_url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin","labels_url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/181/labels{/name}","comments_url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/181/comments","events_url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/181/events","html_url":"https://github.com/webpack/extract-text-webpack-plugin/issues/181","id":153650025,"number":181,"title":"Cannot import .sass files in a .js file","user":{"login":"RyoIkarashi","id":5750408,"avatar_url":"https://avatars.githubusercontent.com/u/5750408?v=3","gravatar_id":"","url":"https://api.github.com/users/RyoIkarashi","html_url":"https://github.com/RyoIkarashi","followers_url":"https://api.github.com/users/RyoIkarashi/followers","following_url":"https://api.github.com/users/RyoIkarashi/following{/other_user}","gists_url":"https://api.github.com/users/RyoIkarashi/gists{/gist_id}","starred_url":"https://api.github.com/users/RyoIkarashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyoIkarashi/subscriptions","organizations_url":"https://api.github.com/users/RyoIkarashi/orgs","repos_url":"https://api.github.com/users/RyoIkarashi/repos","events_url":"https://api.github.com/users/RyoIkarashi/events{/privacy}","received_events_url":"https://api.github.com/users/RyoIkarashi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-08T11:20:25Z","updated_at":"2016-05-24T18:23:36Z","closed_at":null,"body":"Correct me if I'm wrong, but when I import .sass files in a .js file, webpack build fails saying ```Module build failed: ReferenceError: document is not defined```.\r\n\r\nThe error happens when I use extract-text-webpack-plugin, but without the plugin, no errors.\r\nCould you tell me how I can fix this issue?\r\n\r\nHere are my webpack.config.js and index.js which is an entry file for webpack.\r\n\r\n*webpack.config.js*\r\n```\r\nvar webpack = require('webpack');\r\nvar path = require('path');\r\nvar ExtractTextPlugin = require('extract-text-webpack-plugin');\r\nvar autoprefixer = require('autoprefixer');\r\n\r\nmodule.exports = {\r\n  devtool: 'cheap-module-eval-source-map',\r\n  entry: [\r\n    'webpack-hot-middleware/client',\r\n    './src/index.js'\r\n  ],\r\n  output: {\r\n    path: path.join(__dirname, 'dist', 'assets'),\r\n    filename: 'bundle.js',\r\n    publicPath: '/assets/'\r\n  },\r\n  module: {\r\n    preLoaders: [\r\n      {\r\n        test: /\\.js$/,\r\n        exclude: /node_modules/,\r\n        loader: 'eslint-loader'\r\n      }\r\n    ],\r\n    loaders: [\r\n      {\r\n        test: /\\.js$/,\r\n        exclude: /node_modules/,\r\n        loader: 'babel',\r\n        query: { presets: ['react', 'es2015', 'react-hmre'] }\r\n      },\r\n      {\r\n        test: /\\.(scss|sass)$/,\r\n        loader: ExtractTextPlugin.extract('style-loader', ['css-loader', 'postcss-loader', 'sass-loader'])\r\n      },\r\n      {\r\n        test: /\\.(eot|woff|woff2|ttf|svg)(\\?\\S*)?$/,\r\n        loader: 'file?name=fonts/[name].[ext]'\r\n      },\r\n      {\r\n        test: /\\.(jpg|jpeg|gif|png|svg)$/,\r\n        loader:'file?name=images/[name].[ext]'\r\n      }\r\n    ]\r\n  },\r\n  sassLoader: {\r\n    includePaths: [path.join(__dirname, 'src', 'styles')]\r\n  },\r\n  postcss: [\r\n    autoprefixer({\r\n      browsers: ['last 2 version', 'ie >= 9']\r\n    })\r\n  ],\r\n  eslint: {\r\n    configFile: './.eslintrc'\r\n  },\r\n  plugins: [\r\n    new webpack.optimize.OccurenceOrderPlugin(),\r\n    new webpack.HotModuleReplacementPlugin(),\r\n    new webpack.NoErrorsPlugin(),\r\n    new ExtractTextPlugin(\"styles.css\"),\r\n    new webpack.optimize.UglifyJsPlugin({\r\n      compress: {\r\n        warnings: false\r\n      }\r\n    })\r\n  ],\r\n  resolve: {\r\n    extensions: ['', '.js']\r\n  }\r\n};\r\n\r\n```\r\n\r\n*index.js*\r\n```\r\nimport './src/main.scss';\r\ndocument.body.innerText = 'hey';\r\n```\r\n\r\nBelow is the whole error message.\r\n```\r\nModule build failed: ReferenceError: document is not defined\r\n    at eval (eval at <anonymous> (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:555:2), <anonymous>:5:1)\r\n    at Object.<anonymous> (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:555:2)\r\n    at __webpack_require__ (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:519:30)\r\n    at fn (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:50:20)\r\n    at eval (eval at <anonymous> (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:549:2), <anonymous>:6:3433)\r\n    at Object.<anonymous> (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:549:2)\r\n    at __webpack_require__ (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:519:30)\r\n    at /Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:542:37\r\n    at Object.<anonymous> (/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/css-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/postcss-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/node_modules/sass-loader/index.js!/Users/Ryo_Ikarashi/Sites/WP-DEV/dev/sample/src/main.scss:545:10)\r\n    at Module._compile (module.js:425:26)\r\nChild extract-text-webpack-plugin:\r\n    chunk    {0} extract-text-webpack-plugin-output-filename 18.6 kB [rendered]\r\n        [0] ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/main.scss 16.4 kB {0} [built]\r\n        [1] ./src/index.js 694 bytes {0} [built]\r\n        [2] ./~/css-loader/lib/css-base.js 1.51 kB {0} [built]\r\n        [3] ./src/main.scss 0 bytes {0} [built]\r\n```"},"comment":{"url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/comments/221359851","html_url":"https://github.com/webpack/extract-text-webpack-plugin/issues/181#issuecomment-221359851","issue_url":"https://api.github.com/repos/webpack/extract-text-webpack-plugin/issues/181","id":221359851,"user":{"login":"emmajm","id":19557796,"avatar_url":"https://avatars.githubusercontent.com/u/19557796?v=3","gravatar_id":"","url":"https://api.github.com/users/emmajm","html_url":"https://github.com/emmajm","followers_url":"https://api.github.com/users/emmajm/followers","following_url":"https://api.github.com/users/emmajm/following{/other_user}","gists_url":"https://api.github.com/users/emmajm/gists{/gist_id}","starred_url":"https://api.github.com/users/emmajm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmajm/subscriptions","organizations_url":"https://api.github.com/users/emmajm/orgs","repos_url":"https://api.github.com/users/emmajm/repos","events_url":"https://api.github.com/users/emmajm/events{/privacy}","received_events_url":"https://api.github.com/users/emmajm/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T18:23:36Z","updated_at":"2016-05-24T18:23:36Z","body":"I still see the 'window is not defined' error even after trying the suggestion in your linked comment. \r\n\r\n`if (typeof window !== 'undefined') {\r\n  React.render(<Application />, document.getElementById('app'));\r\n}`"}}
{"actor":{"display_login":"emmajm"}}