webpack.config.js

來源:互聯網
上載者:User

標籤:hot   語句   string   efi   query   map   source   UI   自動刪除   

var path = require(‘path‘);var webpack = require(‘webpack‘);var ExtractTextPlugin = require(‘extract-text-webpack-plugin‘);//定義了一些檔案夾的路徑var ROOT_PATH = path.resolve(__dirname,‘src‘);// var APP_PATH = path.resolve(ROOT_PATH, ‘app‘);// var BUILD_PATH = path.resolve(ROOT_PATH, ‘build‘);module.exports = {  entry: ROOT_PATH,  output:{    path: path.resolve(__dirname, ‘assets‘),    filename: ‘bundle.js‘,    publicPath: ‘/assets/‘  },  resolve: {    extensions: [‘.js‘, ‘.jsx‘ ],  },  devServer: {    historyApiFallback: true,    host: ‘localhost‘,    port: ‘9001‘,    // hot: true,    // inline: true,    proxy: {      ‘/nmedia‘: {        target: ‘http://localhost:8080‘,        changeOrigin: true,      }    }  },  devtool: ‘source-map‘,  plugins: [    new webpack.DefinePlugin({//指定生產環境,以便在壓縮時可以讓uglifyjs自動刪除代碼塊的警告語句     ‘process.env.NODE_ENV‘:JSON.stringify(‘production‘)    }),    new webpack.HotModuleReplacementPlugin(),    new ExtractTextPlugin(‘css/styles.css‘),    // new webpack.optimize.UglifyJsPlugin({    //   comments: false, //去掉注釋    //   compress: {    //     warnings: false //忽略警告,不然會有一大推的黃色字型出現    //   }    // })  ],  module: {    rules: [      {        test: /\.js$/,        use: [{          loader: "babel-loader",          options: { presets: ["es2015", "stage-0"] }        }],        include: [path.resolve(__dirname, ‘src‘)]      },      {        test: /\.html$/,        use: ‘raw-loader‘      },      {        test: /\.css$/,        use: ExtractTextPlugin.extract({          fallback: "style-loader",          use: "css-loader"        })      },      { test: /\.less$/, use: ExtractTextPlugin.extract({          fallback: ‘style-loader‘,          use: [            // activate source maps via loader query            {              loader: ‘css-loader‘,              options: { sourceMap: true, importLoaders: 1 }            },            {              loader: ‘less-loader‘,              options: { sourceMap: true }            }          ]        }      )},    ],  }}

 

webpack.config.js

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.