npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wp-react-gs

v1.0.3

Published

[**Autor: Gustavo Silva**](https://github.com/Gustavocrs)

Downloads

3

Readme

Webpack Config

Autor: Gustavo Silva

Documentação Webpack

Documentação Babel

Referências:

React com Webpack - YouTube

Você ENTENDE REALMENTE o Babel e Webpack que roda em seus Projetos JavaScript? // AluraJS #3 - YouTube

Passo 1: Criando o package.json:

⇒ npm init -y

Este comando irá criar o arquivo de configuração padrão.

Passo 2: Instalando as dependências:

⇒ npm i -D webpack webpack-cli

Este comando irá instalar o webpack e suas dependências.

⇒ npm i -D webpack-dev-server

Este comando irá instalar um servidor para as dependências de dev do webpack

⇒ npm i -S react react-dom

Este comando irá instalar o react e o react dom

⇒ npm i -D @babel/core @babel/cli babel-loader @babel/preset-env @babel/preset-react

Este comando irá instalar o babel e as dependências necessárias para que ele funcione

⇒ npm i -D clean-webpack-plugin

Instala plugin para limpar a pasta dist antes do build

⇒ npm i -D html-webpack-plugin

Este comando irá instalar um plugin que gerará um arquivo HTML5 para incluir todos os seus pacotes webpack usando tags.

Passo 3: Criando a estrutura de pastas:

Criar pastas abaixo:

./src

./src/components

./public

Passo 4: Configurando a estrutura de arquivos:

⇒ Criar arquivo src/index.jsx e adicionar as configurações abaixo:

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.jsx';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

⇒ Criar arquivo src/App.jsx e adicionar as configurações abaixo:

import React from "react";
const App = () => {
  return (
    <>
      <h1>New Webpack App</h1>
    </>
  );
};
export default App;

⇒ Criar arquivo src/index.html com a configuração padrão do Emmet (! + Enter) e criar a tag abaixo dentro do :

  <div id="root"></div>

⇒ Alterar o package.json e adicionar/alterar os scripts abaixo:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack-dev-server --mode development --open",
    "build": "webpack --mode production"
  }

Passo 5: Configurando o webpack.config.jsx e .babelrc:

⇒ Criar arquivo src/webpack.config.jsx e adicionar as configurações abaixo:

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
  mode: "development",
  entry: path.resolve(__dirname, "./src/index.jsx"),
  output: {
    filename: "build.js",
    path: path.resolve(__dirname, "static"),
  },
  module: {
    rules: [
      {
        //Jsx & Js
        test: /\.(js|jsx)$/,
        exclude: /node-modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env", "@babel/preset-react"],
          },
        },
      },
      {
        //Svgs
        test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
        type: "asset/inline",
      },
      {
        //Imagens
        test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
        type: "asset/resource",
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: "index.html",
      template: path.resolve(__dirname, "./public/index.html"),
    }),
    new CleanWebpackPlugin(),
  ],
  devServer: {
    static: {
      directory: path.join(__dirname, "public"),
    },
    compress: true,
    hot: true,
    port: 3333,
  },
};

⇒ Criar arquivo .babelrc na pasta raiz e adicionar as configurações abaixo:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
}

Passo 6: Criando o .gitignore:

⇒ Criar arquivo .gitignore com os comandos abaixo:

# dependencies
/node_modules
/.pnp
.pnp.js
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

Passo 7: Rodando o projeto:

⇒ npm start

Passo 8: Rodando o build:

⇒ npm run build