首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Material UI和React

Material UI和React
EN

Stack Overflow用户
提问于 2016-09-12 03:02:54
回答 1查看 364关注 0票数 0

我在让material-ui中的UI工作时遇到了一些问题。我已经在互联网和stackoverflow上搜索了几天来解决我的问题,但我尝试的每一件事都失败了。有没有人能帮我解决这个问题,因为我发现官方指南不适合新手。

提前感谢

编辑:很抱歉缺少代码。我意识到我必须运行npm start才能让它在本地工作。然而,这转移了另一个问题。如何将其部署到我的How服务器?服务器正在public_html文件夹中查找索引文件。由于这依赖于webpack,我不知道如何将其部署到我的服务器上?我是否必须运行node.js或?如有任何后续问题,请提问

webpack-production.config.js:

代码语言:javascript
复制
const webpack = require('webpack');
const path = require('path');
const buildPath = path.resolve(__dirname, 'build');
const nodeModulesPath = path.resolve(__dirname, 'node_modules');
const TransferWebpackPlugin = require('transfer-webpack-plugin');

const config = {
  entry: [path.join(__dirname, '/src/app/app.js')],
  // Render source-map file for final build
  devtool: 'source-map',
  // output config
  output: {
    path: buildPath, // Path of output file
    filename: 'app.js', // Name of output file
  },
  plugins: [
    // Define production build to allow React to strip out unnecessary checks
    new webpack.DefinePlugin({
      'process.env':{
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    // Minify the bundle
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        // suppresses warnings, usually from module minification
        warnings: false,
      },
    }),
    // Allows error warnings but does not stop compiling.
    new webpack.NoErrorsPlugin(),
    // Transfer Files
    new TransferWebpackPlugin([
      {from: 'www'},
    ], path.resolve(__dirname, 'src')),
  ],
  module: {
    loaders: [
      {
        test: /\.js$/, // All .js files
        loaders: ['babel-loader'], // react-hot is like browser sync and babel loads jsx and es6-7
        exclude: [nodeModulesPath],
      },
    ],
  },
};

module.exports = config;
EN

回答 1

Stack Overflow用户

发布于 2016-09-14 13:53:43

您的应用程序入口点是什么?我希望是index.html、main.html或类似的东西。

张贴你的webpack配置,package.json或任何你用来运行webpack的文件。

根据它的构建方式,有多种方法可以运行prod ready build。如果你从某个地方复制了它,它可能有构建脚本。例如,npm run build

我希望它会创建一个名为public的文件夹,或者类似的文件夹,并使用bundle.js javascript文件创建index.html

然后您可以加载到您的you服务器。

在我看来,这是一个很好的例子。http://reactboilerplate.com/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39439614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档