Webpack正在压缩我的整个项目,而不是捆绑js
每当我运行webpack时,它会在项目的根目录下创build一个.tgz文件,而不是创build一个可以包含在html中的bundle.js文件。
这是我的webpackconfiguration:
const path = require('path') module.exports = { context: __dirname, entry: './client/index.js', output: { path: path.resolve('dist'), filename: 'index_bundle.js' }, module: { loaders: [ { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }, { test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ } ] } }
我的项目结构看起来像这样
babel.rc dist node_modules webpack.config.js client - index.html - index.js jslib-1.0.0.tgz < --- this is the unwanted ouput. package.json
我通过npm脚本运行我的webpack,全局安装有一些问题。
:在package.json中:
... "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "pack" : "webpack" }
真的很感激任何帮助或build议。
你可能运行npm pack
而不是npm run[-script] pack
。 一般来说,脚本运行npm run <name>
; 有一些特殊的脚本,如test
,有一个相应的npm
命令,但npm pack
是完全独立的东西。