[WEBPACK] 11. Webpack : Optimize Khi Bundle template (ok)

https://www.youtube.com/watch?v=nGc3fTGRG5k&list=PLJ5qtRQovuEOqsMokakP9ue-y_jXhmCwJ&index=11

C:\Users\Administrator\Desktop\demo\webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
  entry: {
    app: './src/index.js',
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Output Management',
      template: 'src/index.html',
      filename: 'index.html'
    })
  ],
  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
};

C:\Users\Administrator\Desktop\demo\package.json

C:\Users\Administrator\Desktop\demo\src\index.html

Kết quả:

C:\Users\Administrator\Desktop\demo\dist\index.html

Sử dụng chunkhash trong output => filename

C:\Users\Administrator\Desktop\demo\webpack.config.js

C:\Users\Administrator\Desktop\demo\src\index.js

C:\Users\Administrator\Desktop\demo\src\index.html

C:\Users\Administrator\Desktop\demo\package.json

C:\Users\Administrator\Desktop\demo\webpack.config.js

Last updated

Was this helpful?