Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs react样式的组件在生产中不起作用_Reactjs_Webpack - Fatal编程技术网

Reactjs react样式的组件在生产中不起作用

Reactjs react样式的组件在生产中不起作用,reactjs,webpack,Reactjs,Webpack,我已经能够在webpack dev服务器上使用样式化组件,没有任何问题,但是在使用webpack-p--progress--colors或运行webpack-d--progress--colors--watch 在产品中添加的唯一样式是空样式 <style data-styled="" data-styled-version="4.4.1"></style> }, 插件,请注意,如果是生产构建,则使用调试 plugins: debug ? [ new Ht

我已经能够在webpack dev服务器上使用样式化组件,没有任何问题,但是在使用
webpack-p--progress--colors
或运行
webpack-d--progress--colors--watch

在产品中添加的唯一样式是空样式

<style data-styled="" data-styled-version="4.4.1"></style>
},

插件,请注意,如果是生产构建,则使用调试

 plugins: debug ? [
      new HtmlWebpackPlugin({
        template: path.resolve(__dirname, 'template.html')
      })
  ] : [
    new webpack.DefinePlugin({
     "process.env": {
       NODE_ENV: JSON.stringify("production"),
     },
   }),
    new CleanWebpackPlugin(),
    new webpack.optimize.OccurrenceOrderPlugin(),
    new UglifyJsPlugin(),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, 'template.html')
    })
  ],
开发人员服务器设置:

devServer: {
    contentBase: BUILD_DIR,
    historyApiFallback: true,
    watchContentBase: true,
    port: 9000
  },

您是否有使用
createGlobalStyle
创建的全局样式,其中包含css
@import
?从我的网站上删除导入就解决了这个问题。(听起来像是同一个问题)


没有足够的详细信息。请共享您的构建/开发configs@demkovych,我希望我添加了所有必要的内容,而不会弄乱帖子。你的样式化组件babel插件在哪里?@demkovych我之前尝试过安装“babel插件样式化组件”,并添加了
插件:['react-html-attrs'、'transform decorators legacy'、'transform class properties'、'babel plugin styled components']
但仍然不起作用请检查。所有内容都有描述。非常感谢,我不一定理解为什么,但注释掉@import并再次部署才起作用。我正在托管一个react应用程序(使用CreateReact应用程序构建)在Heroku上。嘿,同样的事情…我现在可能只是将我的全局样式移动到css文件中。谢谢你的回答…是时候扫除所有的头发了。
devServer: {
    contentBase: BUILD_DIR,
    historyApiFallback: true,
    watchContentBase: true,
    port: 9000
  },