webpack error
What's up?
Hi,
I am updating the react-cosmos for the latest version, but I got an error and it is not being displayed on the terminal. Can you help me?
Thanks
This is my webpack.config.js
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'eval',
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
plugins: ['transform-decorators-legacy'],
presets: [
'@babel/preset-react',
['@babel/preset-env', { modules: false }],
'@babel/preset-stage-0',
],
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader?sourceMap', 'postcss-loader'],
},
// for react-widgets
{
test: /\.gif$/,
use: 'url-loader?mimetype=image/png',
},
{
test: /\.woff(2)?(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/,
use: 'url-loader?mimetype=application/font-woff',
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]+\.[0-9]+\.[0-9]+)?$/,
use: 'file-loader?name=[name].[ext]',
},
],
},
plugins: [
new webpack.ProvidePlugin({
React: 'react',
}),
new HtmlWebpackPlugin(),
],
};
Hi @mitsuishihidemi, can you also check the browser console for errors? Thanks!
Also, what is the current version (can be stable or beta)? And what version was previously working for you?
I was using 3.7.1 and moved to 4.5.0

here is my cosmos.config.js
module.exports = {
fileMatch: ['**/src/demo/fixtures/**/*.js'],
globalImports: [
'node_modules/github-markdown-css/github-markdown.css',
'node_modules/prismjs/themes/prism-okaidia.css',
'node_modules/react-widgets/dist/css/react-widgets.css',
'src/demo/index.css',
'src/demo/index.js',
],
proxiesPath: './redux-proxy.js',
hot: true,
publicUrl: 'src/demo',
watchDirs: ['src'],
hostname: '0.0.0.0',
port: 8989,
webpackConfigPath: './webpack.config.demo',
};
Can you please tell me your webpack version as well? If you can share your full list of package.json dependencies/devDependencies even better.
It seems like you're using an older webpack version (pre v4), because you're using module.loaders. So I need your exact webpack version to replicate your setup.
Even better if you can provide a public repository that reproduces this issue!
Hi,
Thanks for replied, I am using webpack 3.0.0
{
"dependencies": {
"bem-cn": "^2.1.3",
"eslint": "3.19",
"prismjs": "^1.13.0",
"react-click-outside": "^2.2.0",
"react-paginate": "^4.2.0",
"styled-components": "^3.2.5"
},
"peerDependencies": {
"react": "^16.2.0",
"react-bootstrap": "^0.32.1",
"react-widgets": "^4.2.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.40",
"@babel/core": "^7.0.0-beta.40",
"@babel/plugin-transform-async-to-generator": "^7.0.0-beta.40",
"@babel/polyfill": "^7.0.0-beta.40",
"@babel/preset-env": "^7.0.0-beta.40",
"@babel/preset-react": "^7.0.0-beta.40",
"@babel/preset-stage-0": "^7.0.0-beta.40",
"autoprefixer": "^7.1.4",
"babel-core": "^7.0.0-0",
"babel-eslint": "~7.1.0",
"babel-jest": "^22.4.1",
"babel-loader": "^8.0.0-beta.2",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-react-require": "^3.0.0",
"babel-plugin-remove-nonjs": "^0.1.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-require-ignore": "^0.0.2",
"codecov": "^2.2.0",
"css-loader": "^0.26.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-context-patch": "^0.0.8",
"eslint-config-airbnb": "^12.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-prettier": "^2.6.1",
"eslint-plugin-react": "^6.10.3",
"extract-text-webpack-plugin": "^2.0.0-beta",
"faker": "^4.1.0",
"file-loader": "^0.10.1",
"github-markdown-css": "^2.10.0",
"html-webpack-plugin": "^2.30.1",
"husky": "^0.14.3",
"jest": "^22.4.2",
"jest-styled-components": "next",
"lint-staged": "^7.2.0",
"lodash.clonedeep": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.omit": "^4.5.0",
"lodash.range": "^3.2.0",
"moment": "^2.18.1",
"normalize.css": "^7.0.0",
"postcss-color-function": "^2.0.1",
"postcss-custom-properties": "^5.0.1",
"postcss-each": "^0.9.3",
"postcss-loader": "^1.3.3",
"postcss-nested": "^1.0.0",
"postcss-simple-vars": "^3.0.0",
"prettier": "^1.13.7",
"prettier-eslint": "^8.8.2",
"prop-types": "^15.5.10",
"react": "^16.3.2",
"react-addons-test-utils": "^15.4.2",
"react-bootstrap": "^0.32.1",
"react-cosmos": "^3.7.1",
"react-cosmos-redux-proxy": "^3.6.1",
"react-dom": "^16.3.2",
"react-element-to-jsx-string": "^14.0.1",
"react-markdown": "^3.3.0",
"react-redux": "^5.0.2",
"react-test-renderer": "^16.2.0",
"react-widgets": "^4.2.0",
"react-widgets-moment": "^4.0.4",
"recompose": "^0.26.0",
"redux": "^3.6.0",
"redux-form": "^6.6.0",
"redux-logger": "^3.0.1",
"redux-thunk": "^2.2.0",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint-config-standard": "^17.0.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^0.4.0",
"url-loader": "^0.5.8",
"webpack": "3.0.0"
}
}
I tried to reproduce your issue but I get this build error
Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.
And I'm not up to date with Babel 7 yet (which is still beta). Unfortunately I can't spend more time debugging like this. If you have a public repo that reproduces this issue I'll be able to understand it and come up with a solution.
But if we're lucky this issue is already fixed. Can you try installing [email protected] and see if anything changes? It contains a fix for a similar issue (#753).
Thanks for your help, I will try with the latest version of react-cosmos, and if does not work I will set a public repo for you.
@mitsuishihidemi Any luck? Let's close this issue if you managed to get Cosmos working.
@mitsuishihidemi @skidding, was there ever any resolution on this? I just lined things up and got the custom webpack config properly extended but am still getting the error in the playground but with no actual error in the terminal and the same browser 404 for _loader.html.
Let me know if you need any more context!
react-cosmos: 4.8.1 webpack: 4.29.6 babel-loader: 7.1.2
// cosmos.config.js
const baseConfig = require("./webpack.config.js").baseConfig;
module.exports = {
webpack: () => {
return baseConfig({});
},
watchDirs: ["src/components"]
};
From other tickets, I've seen references to the html-webpack-plugin, looking at the playground I'm seeing:

☝️ should there be "html-webpack-plugin" under the "plugin" key in "deps"?