itstrive / striveCode

some demo and js Knowledge points records :cn: :cloud: :snowflake:
108 stars 83 forks source link

Webpack常用的Loader和插件 #17

Open itstrive opened 5 years ago

itstrive commented 5 years ago

常用的loader

loader简单使用

module.exports = {
 module: {
    rules: [
      { test: /\.css$/, use: 'css-loader' }
    ]
  }
};

常用的插件(有webpack自带的,有第三方的)

plugin简单实用:

// Webpack .config.js
const HtmlWebpack Plugin = require('html-Webpack -plugin');
const Webpack  = require('Webpack ');

const config = {
  plugins: [
    new Webpack .optimize.UglifyJsPlugin(), //webpack自带的压缩
    new HtmlWebpack Plugin({template: './src/index.html'})
  ]
};

module.exports = config;