• webpack.config.js


    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 }
                }
              ]
            }
          )},
        ],
      }
    
    }
  • 相关阅读:
    删除字符串前后的空格
    Python中定义“私有”成员变量和成员函数
    linux 线程
    进程虚拟内存模型
    守护进程
    FIFO
    linux 中的 wait 函数和 waitpid 函数
    孤儿进程和僵尸进程
    linux 中的 exec 函数族
    linux中的fork函数
  • 原文地址:https://www.cnblogs.com/iagw/p/6864243.html
Copyright © 2020-2023  润新知