當我捆綁我的源代碼時,Webpack會發出警告,因爲它無法解析'sha3'模塊。使用Webpack捆綁sha3 /二進制模塊
$ npm run build
WARNING in ./~/keccakjs/index.js
Module not found: Error: Can't resolve 'sha3' in '<PROJ>\node_modules\keccakjs'
@ ./~/keccakjs/index.js 2:19-34
@ ./~/<lib>/index.js
@ ./lib/<file>.js
原因是該sha3 library沒有js文件。
創建庫<凸出> \ node_modules \沙三段\建立\發佈\ sha3.lib和對象<凸出> \ node_modules \沙三段\建立\發佈\ sha3.exp
我可以在我的項目中運行require('sha3')
,但webpack無法解決它。
我看着docs here,關於webpack如何解析庫文件。
是否有人可以指示我如何將sha3包含到我的包中?
我的WebPack配置:利用的WebPack二進制裝載機從here
module.exports = {
target: 'node',
entry: "./<lib>.js",
devtool: "source-map",
node: {
__dirname: false,
__filename: false,
},
output: {
path: "./dist",
filename: "<lib>.min.js"
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
}
看起來很有前途! –
獲取'配置有一個未知屬性'loader'? –
哎呀,對不起,這應該是在模塊對象中,當我看到module.exports時我覺得有點困惑。編輯! –