webpack 基本配置 - 01

來源:互聯網
上載者:User

標籤:

 1 const webpack = require(‘webpack‘); 2 const path = require(‘path‘); 3 const HtmlWebpackPlugin = require(‘html-webpack-plugin‘); 4 const ExtractTextPlugin = require("extract-text-webpack-plugin"); 5 const CleanPlugin = require(‘clean-webpack-plugin‘); 6  7 const PATH = { 8      src:path.join(__dirname, ‘src‘), 9      build:path.join(__dirname, ‘build‘)10 }11 12 module.exports ={13 14     entry:{15         app:PATH.src,16         // vendor:[17         //     PATH.src+‘/common/jquery‘,18         //     PATH.src+‘/common/layer/layer‘19         // ]20     },21     output:{22         // publicPath 配置上線時的路徑23         // 可有效解決css loader 和url loader路徑不一致問題24         publicPath:‘/‘,25         path:PATH.build,26         filename:‘./js/[name].js‘,27         chunkFilename:‘./js/[name].chunck.js‘28     },29     module:{30         loaders:[31             {32                 test:/\.(png|gif|jpg|jpeg)$/,33                 exclude: /node_modules/,34                 loader:‘url?limit=7000&name=images/[name].[ext]‘,                35             },36             {37                 test:/\.css$/,38                 exclude: /node_modules/,39                 loader: ExtractTextPlugin.extract("style-loader", "css-loader")40             }41         ]42     },43     plugins:[44         new CleanPlugin([‘build‘]),45         new ExtractTextPlugin(‘css/[name].css‘),46         new HtmlWebpackPlugin({47             title:‘webpack demo‘,48         }),49         // 壓縮50         // new webpack.optimize.UglifyJsPlugin({51         //     compress:{52         //         warnings:false53         //     }54         // })55     ],56     devServer: {57         compress:true,58        inline: true,59        compiler:{60                hot:true61        }62        63     }64 65 }

 

webpack 基本配置 - 01

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.