Giter Site home page Giter Site logo

f_1_weather_forecast's Introduction

Alt text

Configuring a project

In the project directiory:

npm install

npm init -y

create scripts for package.json:

    "scripts": {
        "start": "webpack --mode=development --watch",
        "build": "webpack --mode-production",
        ...
        ...
    },

Installations

In the project directiory:

Install: webpack, webpack-cli, webpack-dev-server

npm i webpack webpack-cli webpack-dev-server -D


Install: @babel/core, babel-loader, @babel/preset-env, @babel/preset-react

npm install @babel/core babel-loader @babel/preset-env @babel/preset-react


Install: react, react-dom

npm install react react-dom


Install: typescript

npm install typescript @types/react @types/react-dom

npm install ts-loader


Install: styleloader, css-loader

npm install style-loader css-loader


Install: html-webpack-plugin

npm i html-webpack-plugin


Install: react-bootstrap, bootstrap

npm install react-bootstrap bootstrap


Install: axios

npm install axios


Install: react-yandex-maps

npm install --save react-yandex-maps

in my case: npm install --save react-yandex-maps

Configurations

Configure webpack.

In the project root directory:

touch webpack.config.js


webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    mode: 'development',
    devtool: "source-map",
    entry: "./src/index.tsx",
    output: {
        path: path.join(__dirname, "/dist"),
        filename: "bundle.js"
    },

    resolve:{
        extensions: [".js", ".jsx", ".json", ".ts", ".tsx"]
    },

    module: {
        rules: [
            {
                test: /\.(ts|tsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: "ts-loader"
                }
            },
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"]
            }
        ]
    },
    
    plugins: [
        new HtmlWebpackPlugin({
            template:"./src/index.html"
        })
    ]

};

Configure typescript.

touch tsconfig.json


tsconfig.json

{
    "compilerOptions": {
        "jsx": "react"
    },
    "exclude": [
        "node_modules"
    ]
}

./src/components

./components

./src/styles

./styles

./src

./src$ touch index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>F1. Exercise</title>
</head>
<body>
    <div id="root"></div>
</body>
</html>

./src$ touch index.tsx

import * as React from "react";
import { render } from "react-dom";

/* 
* index.tsx подключает App.tsx к index.html с помощью ReactDOM
* поэтому нам необходимо их импортировать
**/

// import ReactDOM from "react-dom/client"; 
import App from "./components/App"

/*
* Все компоненты собираются в App.tsx
* App.tsx - это верхний уровень, внутрь которого подгружаются
* остальные компонентыю
* Далее, всё рендерится с помощью ReactDOM и подвязывается
* к index.html через <div id="root">
**/

render(<App/>, document.getElementById("root"));

./src$ mkdir components

import * as React from "react"; 

function App() {
    return (
        <>
            <h1>Hello</h1>
        </>
    )
}

export default App;

./src$ mkdir styles


f_1_weather_forecast's People

Contributors

expowheella avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.