“webpack-geting_strted” Código de respuesta

webpack-geting_strted

mkdir webpack-demo
cd webpack-demo
npm init -y
npm install webpack webpack-cli --save-dev
Bewildered Badger

webpack-geting_strted

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting Started</title>
    <script src="https://unpkg.com/[email protected]"></script>
  </head>
  <body>
    <script src="./src/index.js"></script>
  </body>
</html>
Bewildered Badger

webpack-geting_strted

webpack-demo
  |- package.json
  |- package-lock.json
+ |- webpack.config.js
  |- /dist
    |- index.html
  |- /src
    |- index.js
Bewildered Badger

webpack-geting_strted

function component() {
  const element = document.createElement('div');

  // Lodash, currently included via a script, is required for this line to work
  element.innerHTML = _.join(['Hello', 'webpack'], ' ');

  return element;
}

document.body.appendChild(component());
Bewildered Badger

webpack-geting_strted

npm install --save lodash
Bewildered Badger

webpack-geting_strted

const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },
};
Bewildered Badger

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código