webpack视图生成的源映射

时间:2017-04-26 04:25:30

标签: webpack source-maps

我正在使用webpack编写一个简单的程序。我想查看webpack生成的sourcemap(.map)文件。这是我的webpack配置

var path = require('path');
var webpack = require('webpack');

module.exports = {
    context: path.resolve('src'),
    entry: {
        app: './app.jsx',
        vendor: './vendor.js',
    },
    output: {
        path: path.resolve('build'),
        filename: '[name].js',
        publicPath: '/public/assets',
        sourceMapFilename: 'source.map'
    },
    resolve: {
        // only discover files that have those extensions
        extensions: ['.ts', '.js', '.jsx', '.json', '.css', '.scss', '.html'],
    },
    module: {
        loaders: [{
            test: /\.jsx$/,
            exclude: /node_modules/,
            loader: 'babel-loader'
        },
        {
            test: [/\.css$/, /\.scss$/],
            loader: 'style-loader!css-loader?modules=true&localIdentName=[name]__[local]___[hash:base64:5]'
        }]
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        }),
    ],
    devServer: {
        historyApiFallback: {
            index: 'index.html'
        },
    },
    devtool: 'source-map'
}

然而,当我运行build时,我只看到app.js和vendor.js文件。没有.map文件生成。如何查看.map文件。

第二个问题是,即使没有.map文件,Chrome也能够显示实际的源文件,如果没有实际的.map文件,该怎么做呢?

0 个答案:

没有答案