在编译甚至`stats:false`集时,Webpack输出大量的消息

时间:2017-11-24 07:08:54

标签: webpack silent verbose

我需要在远程服务器中的docker构建过程中构建它,所有输出消息将在松弛通道中打印。部署过程在服务器中停止,但由于长输出消息,我无法检查哪个部分出错。我需要隐藏它

这是命令:NODE_ENV=production node_modules/.bin/webpack --config webpack.config.js --hide-modules

配置:

'use strict';
const path = require('path');
const glob = require('glob');
const webpack = require('webpack');
const OptimizeJsPlugin = require('optimize-js-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const LiveReloadPlugin = require('webpack-livereload-plugin');

const configs = [{
    entry: {
        // 'main': './scripts/boot.aot.ts',
        'jit': './scripts/boot.jit.ts',
        // 'boot.common': './scripts/boot.common.ts'
    },
    context: path.join(process.cwd(), '.'),
    output: {
        path: path.join(process.cwd(), 'public-html/dist'),
        filename: '[name].js'
    },
    module: {
        rules: [{
            test: /\.ts$/,
            use: ['awesome-typescript-loader', 'angular2-template-loader']
        }, {
            test: /\.html$/,
            use: 'html-loader?minimize=false'
        }]
    },
    plugins: [
        new webpack.ProgressPlugin(),
        new webpack.ContextReplacementPlugin(
            // The (\\|\/) piece accounts for path separators in *nix and Windows
            /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
            path.join(process.cwd(), '.')
        ),
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery"
        })
    ],
    resolve: {
        modules: [
            'node_modules',
            path.resolve(process.cwd(), '.')
        ],
        alias: {
            'jquery': require.resolve('jquery'),
        },
        extensions: ['.ts', '.js']
    },
    stats: false,
    performance: {
        hints: false
    }
}, {
    name: 'styles',
    entry: {
        'main': './styles/layout.scss',
    },
    output: {
        path: path.join(process.cwd(), 'public-html/dist'),
        filename: '[name].js',
    },
    module: {
        rules: [
            {
                test: /\.scss$/,
                use: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: [
                        'css-loader?minimize=true!',
                        {
                            loader: 'sass-loader',
                            options: {
                                // Special config for Material Component SCSS importing
                                includePaths: ['node_modules'].map((d) => {
                                    return path.join(__dirname, d);
                                })
                            }
                        }
                    ]
                }),
            },
            { test: /\.css$/, loader: 'style-loader!css-loader?minimize=true' },
            { test: /\.(gif|png|jpe?g)$/i, loader: 'file-loader?name=dist/images/[name].[ext]' },
            { test: /\.woff2?$/, loader: 'url-loader?name=fonts/[name].[ext]&limit=10000&mimetype=application/font-woff' },
            { test: /\.(ttf|eot|svg)$/, loader: 'file-loader?name=fonts/[name].[ext]' },
        ],
    },
    plugins: [
        new ExtractTextPlugin({
            filename: '[name].css',
        }),
        new LiveReloadPlugin()
    ],
}];

if (process.env.NODE_ENV !== 'production') {
    configs[0].devtool = false;
    // 'source-map';
    configs[0].plugins = configs[0].plugins.concat([
        new webpack.DefinePlugin({
            'WEBPACK_ENV': '"dev"'
        })
    ]);
} else {
    configs[0].devtool = false;
    configs[0].plugins = configs[0].plugins.concat([
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                screw_ie8: true,
                warnings: false,
            },
            comments: false,
            sourceMap: false,
        }),
        new OptimizeJsPlugin({
            sourceMap: false,
        }),
        new webpack.DefinePlugin({
            WEBPACK_ENV: '"production"',
        }),
    ]);
}

module.exports = configs;

和tsconfig.js

{
    "compilerOptions": {
        "baseUrl": "./",
        "target": "es5",
        "module": "es2015",
        "moduleResolution": "node",
        "declaration": true,
        "noImplicitAny": false,
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "outDir": "./dist",
        "rootDir": "./",
        "skipLibCheck": true,
        "typeRoots": [
            "./node_modules/@types",
            "./typings"
        ],
        "types": [
            "node",
            "jquery",
            "gapi",
            "gapi.auth2"
        ],
        "lib": [
            "dom",
            "es2015"
        ]
    },
    "compileOnSave": false,
    "buildOnSave": false,
    "files": [
        "./typings/hb-ng2-sdk.d.ts",
        "./scripts/module.ts"
    ],
    "exclude": [
        "node_modules",
        "dist",
        "**/*.ngfactory.ts",
        "**/*.shim.ts"
    ],
    "awesomeTypescriptLoaderOptions": {
        "useBabel": true,
        "useCache": true,
        "silent": true
    },
    "angularCompilerOptions": {
        "genDir": "./aot",
        "skipMetadataEmit" : false,
        "entryModule": "scripts/module#AppModule"
    }
}

0 个答案:

没有答案