Answer the question
In order to leave comments, you need to log in
Why does the code display an empty page when building react via webpack?
after the introduction of the webpack command, the component is assembled but when run, the react code does not work
const path = require('path'),
webpack = require('webpack');
module.exports = {
//context - путь для всех файлов
context: __dirname+'/src/',
//entry - что передавать
entry: {
common: "./test.js"
},
//output - куда передавать
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
babelrc: false,
presets: ["react"], //babel-preset-react-native
cacheDirectory: true
}
}]
}
};
import React, { Component } from 'react';
import { render } from 'react-dom';
ReactDOM.render(
<h1>djkkdkdk</h1>,
document.getElementById("root")
);
<div id="root"></div>
Answer the question
In order to leave comments, you need to log in
import React, { Component } from 'react';
import ReactDOM, { render } from 'react-dom';
- so decided
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question