“webpack-getting_strted” Réponses codées

webpack-getting_strted

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

webpack-getting_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-getting_strted

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

webpack-getting_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-getting_strted

npm install --save lodash
Bewildered Badger

webpack-getting_strted

const path = require('path');

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

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code