当前位置: 移动技术网 > IT编程>网页制作>Html5 > webpack管理输出

webpack管理输出

2018年11月11日  | 移动技术网IT编程  | 我要评论

快捷酒店,火影风云绝,为什么我家玩cf很卡

管理html的bundle依赖

html-webpack-plugin可以自动给html添加bundle文件

npm install --save-dev html-webpack-plugin

  const path = require('path');
+ const htmlwebpackplugin = require('html-webpack-plugin');

  module.exports = {
    entry: {
      app: './src/index.js',
      print: './src/print.js'
    },
+   plugins: [
+     new htmlwebpackplugin({
+       title: 'output management'
+     })
+   ],
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
  };

清理dist文件夹

 const path = require('path');
  const htmlwebpackplugin = require('html-webpack-plugin');
+ const cleanwebpackplugin = require('clean-webpack-plugin');

  module.exports = {
    entry: {
      app: './src/index.js',
      print: './src/print.js'
    },
    plugins: [
+     new cleanwebpackplugin(['dist']),
      new htmlwebpackplugin({
        title: 'output management'
      })
    ],
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, 'dist')
    }
  };

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网