javascript - webpack打包出现react-dom相关错误
问题描述
login.js代码import React from ’react’;import ReactDOM from ’react-dom’;function tick() { const element = ( <p> <h1>Hello, world!</h1> <h2>It is {new Date().toLocaleTimeString()}.</h2> </p> ); ReactDOM.render( element, document.getElementById(’root’) );}webpack.config.js代码
const webpack = require(’webpack’);const path=require(’path’);module.exports=(env)=>{ return {entry:{ main:’./login.js’, vendor1:’React’, vendor2:’ReactDOM’},output:{ filename:’[name].bundle.js’, path:path.resolve(__dirname,’dist’)}, module: { rules: [ {test: /.(js|jsx)$/,loader: ’babel-loader’ } ] },plugins:[ new webpack.optimize.CommonsChunkPlugin({name:’manifest’ }),/* new webpack.optimize.CommonsChunkPlugin({name:’vendor1’,minChunks:(module)=>{ return module.context&&module.context.indexOf(’node_modules’)!==-1;} }), new webpack.optimize.CommonsChunkPlugin({name:’vendor2’,minChunks:(module)=>{ return module.context&&module.context.indexOf(’node_modules’)!==-1;} })*/] }}setInterval(tick, 1000);控制台错误
WARNING in D:/node/likeread/~/React/lib/ReactPropTypesSecret.jsThere are multiple modules with names that only differ in casing.This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.Use equal casing. Compare these module identifiers:* D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesReactlibReactPropTypesSecret.js Used by 1 module(s), i. e. D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesReactlibcheckReactTypeSpec.js* D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesreactlibReactPropTypesSecret.js Used by 1 module(s), i. e. D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesreactlibcheckReactTypeSpec.jsERROR in Entry module not found: Error: Can’t resolve ’ReactDOM’ in ’D:nodelikereadpublicjavascripts’
问题解答
回答1:你把ReactDOM.render()写在tick方法中是什么意思?
相关文章:
1. docker start -a dockername 老是卡住,什么情况?2. javascript - 在静态页面上用load 引入的页面文件问题?3. css3 - 微信前端页面遇到的transition过渡动画的bug4. HTML5禁止img预览该怎么解决?5. vue.js - vuejs 折叠面板的展开收缩动画应该怎么实现?用vue自带的过渡效果还是css3?6. 微信chooseImage接口部分机型选择图片后莫名其妙的跳转其他页面7. javascript - babel转码目标文件下有除了.js的其他文件,转码后只有.js文件。8. javascript - vue el 重复挂载 同一个实例9. c++ - win764位环境下,我用GCC为什么指针占8个字节,而long是4个字节?10. ueditor上传服务器提示后端配置项没有正常加载,求助!!!!!