我的webpack配置文件
生活随笔
收集整理的這篇文章主要介紹了
我的webpack配置文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先把配置文件拷貝出來
var path = require('path');
var webpack = require('webpack');var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var TransferWebpackPlugin = require('transfer-webpack-plugin');
var newHtmlWebpackPlugin = function (filename, url) {
??? return new HtmlWebpackPlugin({
??????????????? favicon:'./src/favicon.ico',
??????????????? filename: filename,
??????????????? template: url,
??????????????? inject:false
??????????? });
};
?
module.exports = {
??? entry: {
??????? //郵件
??????? 'email_create': './src/scripts/email-create.js',
??????? 'email_review': './src/scripts/email-review.js',
??????? 'email_send': './src/scripts/email-send.js',
??????? 'email_statistic': './src/scripts/email-statistic.js'
??? },
??? output: {
??????? path: path.join(__dirname, 'dist'),
??????? filename: './scripts/[name].js',
??????? publicPath: ""
??? },
??? //devtool: "eval", //***上線關閉***
??? module: {
??????? loaders: [
??????????? {
??????????????? test: /\.html$/,
??????????????? loader: 'html-loader'
??????????? },
??????????? {
??????????????? test: /\.css$/,
??????????????? loader: ExtractTextPlugin.extract("style-loader", "css-loader")
??????????? },
??????????? {
??????????????? test: /\.(pdf.*|eot.*|woff.*|woff2.*|ttf.*|svg.*|png.*|jpg.*|gif.*)$/,
??????????????? loader: 'file-loader?name=/images/[name].[ext]'
??????????? }
??????? ]
??? },
??? plugins: [
??????? //把指定文件夾xia的文件復制到指定的目錄
??????? new TransferWebpackPlugin(
??????????? [
??????????????? {from: 'audios', to: 'audios'}
??????????? ],
??????????? path.resolve(__dirname,'./src')
??????? ),
??????? // new webpack.optimize.UglifyJsPlugin({ //***上線打開***
??????? //???? compress: {
??????? //???????? warnings: false
??????? //???? },
??????? //???? sourceMap: true,//這里的soucemap 不能少,可以在線上生成soucemap文件,便于調試
??????? //???? mangle: true
??????? // }),
??????? new webpack.optimize.CommonsChunkPlugin('global', './scripts/bundle.js'),
??????? new ExtractTextPlugin('styles/[name].css'),
??????? new webpack.ProvidePlugin({
??????????? $: "jquery",
??????????? jQuery: "jquery",
??????????? "window.jQuery": "jquery"
??????? }),
??????? //郵件
??????? newHtmlWebpackPlugin('email-create.html', './src/email-create.html'),
??????? newHtmlWebpackPlugin('email-review.html', './src/email-review.html'),
??????? newHtmlWebpackPlugin('email-send.html', './src/email-send.html'),
??????? newHtmlWebpackPlugin('email-statistic.html', './src/email-statistic.html')
??? ],
??? resolve:{
??????? extensions: ['','.js','.json'],
??????? alias: {
????????? 'jquery': path.join(__dirname, './src/scripts/lib/jquery-1.10.2.min.js')
??????? }
??? },
??? devServer: { //***上線關閉***
??????? historyApiFallback:false,
??????? contentBase:"./dist",
??????? hot: false,
??????? inline: true,
??????? proxy: {
??????????? '/*/*': {
??????????????? changeOrigin: true,
??????????????? //target: 'http://yx.nymph.cc',
??????????????? target: 'http://test.nymph.cc',
??????????????? secure: false,
??????????? }
??????? }
??? }
};
總結
以上是生活随笔為你收集整理的我的webpack配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【重点EI会议推荐】机器学习主题方向论文
- 下一篇: 【Python】Pandas group