zoukankan      html  css  js  c++  java
  • [AngualrJS + Webpack] Production Source Maps

    When you uglify your Angular code with Webpack's uglify plugin, debugging your application can be a nightmare. See how easy it is to add source maps to your bundle so you can easily debug even in production.

    Add source map to the production:

    if(process.env.NODE_ENV === "production"){
        config.output.path = __dirname + "/dist";
        config.plugins.push(new webpack.optimize.UglifyJsPlugin()); // Uglify js
        config.devtool = 'source-map';
    }
    var webpack = require('webpack')
        path = require('path');
    
    path.resolve(__dirname, "app");
    
    var config = {
        context: __dirname + '/app',
        entry: './index.js',
        output: {
            path: __dirname + '/app',
            filename: 'bundle.js'
        },
        plugins: [
            new webpack.DefinePlugin({
               ON_TEST: process.env.NODE_ENV === "test"
            })
        ],
        module: {
            loaders: [
                {test: /.js$/, loader: 'ng-annotate-loader!babel-loader', exclude: /node_modules/},
                {test: /.html$/, loader: 'html-loader', exclude: /node_modules/},
                {test: /.css$/, loader: 'style!css', exclude: /node_modules/},
                {test: /.styl/, loader: 'style!css!stylus', exclude: /node_modules/}
            ]
        }
    };
    
    if(process.env.NODE_ENV === "production"){
        config.output.path = __dirname + "/dist";
        config.plugins.push(new webpack.optimize.UglifyJsPlugin()); // Uglify js
        config.devtool = 'source-map';
    }
    
    module.exports = config;

  • 相关阅读:
    8102Java的学习呼声有所下降,2019年还值得学习吗
    大数据开发面试题详解:Hadoop的运行原理
    总结:java大神的自学路线
    大数据开发工程师必看书籍
    java主要编程工具
    bzoj3791 作业
    bzoj3750 [POI2015]Pieczęć
    bzoj1143 [CTSC2008]祭祀river
    bzoj2718 [Violet 4]毕业旅行
    poj3237 Tree
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4798270.html
Copyright © 2011-2022 走看看