请教关于webpack压缩nodejs代码的问题
发布于 8 年前 作者 einsqing 5982 次浏览 来自 问答
// world.js
var Result = "hello world!";
module.exports = Result;

//index.js
var http = require('http');
var World = require('./world');

http.createServer(function (request, response) {
	response.writeHead(200, {'Content-Type': 'text/plain'});
	response.end('Hello World\n'+World);
}).listen(8888);

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');

//webpack.config.js
 var webpack = require('webpack');
 module.exports = {
     entry: './index.js',
     output: {
         path: './bin',
         filename: 'app.bundle.js',
         libraryTarget: 'commonjs'
     },
     plugins: [
         new webpack.optimize.UglifyJsPlugin({
             compress: {
                 warnings: false
             }
         })
     ]
 };

报错如下

untitled1.png

请教webpack如何压缩混淆nodejs代码?

3 回复

如果只是压缩混淆为何是用webpack。。。。。 这个前端的打包工具你用在这。。。。

@AnzerWall 有人推荐的,不过研究了一圈好像也实现不了。

From KoaHub.js

wepack前后端应该都可以混淆啊,我最近就是用它混淆后台代码的 自豪地采用 CNodeJS ionic

回到顶部