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;

  • 相关阅读:
    12、SpringBoot-CRUD增加数据
    12、SpringBoot-CRUD增加数据
    Cache操作类
    pythonhttp
    python学习
    自动化测试LoadRunner
    pythonweb自动化测试
    python学习工具篇
    python学习
    自动化测试之python安装
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4798270.html
Copyright © 2011-2022 走看看