Webpack plug-in

Plug-in unit

plugins:[
    new ExtractTextPlugin.extrct({
    
        
    })
//Create HTMLNew HtmlWebpackPlugin ({)title:"first page",
        filename:"index.html",
        template:"/index.html,
        // true Displayed in body false does not display (default).inject:true "body"
    }),
    // Heat replacementNew webpack.HotModuleReplacementPlugin ()]devtool:
    "eval-source-map"
    "cheap-source-map"
    
    
4.0Before: extract-text-webpack-plugin4.0:extract-text-webpack-plugin@next
Service
devServer:{
    host:'localhost',
    port:8080,
    contentBase:".",
    overlay:true,
    inline:true,
    hot:true,
    before(app){
        app.get('/api',(req,res)=>{
            res.end()
        })
    }
}

Solve the problem

//function resolve(pathname{

    return path.join(__dirname,pathname);    
//}

resolve:{
    alias:{
        common:ressolve('src/common');
    }
}

Setting multiple entry files

function entries(){
    let temp = {};
    let pathname = path.join(__dirname,'src');
    let files =fs.readdirSync(pathname);
    
    files.map(file=>{
        let pathUrl = path.join(pathname,file);
        let stats = fs.statSync(pathUrl);
        if(stats.isFile()){
           let key = pathUrl.basename(pathUrl,'.js'); temp[key]=pathUrl;
        }
    })
    return temp;
}
// Static setting multiple entry files<! --entry:{--><!--    app:resolve('src/app.js'),-->
<!--    main:resolve('src.main.js')-->
<!--}-->
// Dynamic setup of multiple entry filesEntry:entries ()NPM I -D cross-env cross platform settings environment variable plug-insNPM I -D webpack-merge merge1. introduce meige=re first.Quire (webpack-merge);NPM I -D friendly-errors-webpack-pluginNew friendly-errors-webpack-plugin ({)})NPM I -D node-notifier error message prompt

Leave a Reply

Your email address will not be published. Required fields are marked *