Skip to content

Instantly share code, notes, and snippets.

@idhowardgj94
Last active October 25, 2019 06:49
Show Gist options
  • Save idhowardgj94/10232adc18d6f5e64ae03c92caf851e7 to your computer and use it in GitHub Desktop.
Save idhowardgj94/10232adc18d6f5e64ae03c92caf851e7 to your computer and use it in GitHub Desktop.
note
mkdir practice
cd practice/

npm init -y
# init package.json file

npm install react react-dom
npm install --save-dev @babel/core @babel/preset-env @babel/preset-react webpack webpack-cli webpack-dev-server babel-loader css-loader style-loader html-webpack-plugin
var path = require('path')

module.exports = {
  entry: './app/index.js',
  output: {
    path: path.resolve(__dirname, 'dist')
    filename: 'index_bundle.js',
  },
  module: {
    rules: [
      { test: /\.(js)$/, use: 'babel-loader'},
      { test: /\.(css)$/, use: ['style-loader', 'css-loader']}
    ]
  },
  mode: 'development',
  pulgins: [
    new HtmlWebpackPlugin({
      template: 'app/index.html'
    })
  ]
}
  • style-loader: take css been required and insert into page.
  • css-loader: look for any css import, ie url('./background.png')

html-webpack-pulgin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment