托管与 webpack 捆绑的 Web 应用程序 [英] Hosting web app bundled with webpack
问题描述
我在 Stephen Grider 的 ReduxSimpleStarter 之上构建了一个网络应用程序,这是一个 react-redux 样板.它使用 Webpack 进行捆绑.现在我想在 firebase 上托管我的应用.当我这样做时,捆绑不起作用,我只剩下一个简单的 index.html.
I have built a web app on top of Stephen Grider's ReduxSimpleStarter, a react-redux boilerplate. It uses Webpack for bundling. Now I want to host my app on firebase. When I do so, the bundling doesn't work, and I am left with a simple index.html.
有人可以解释一下我如何为非本地托管的应用程序触发 Webpack 捆绑吗?
Could someone please explain how I trigger Webpack bundling for an app that is not locally hosted?
这些文件可能是相关的,但我不确定.
These files might be relevant, though I am not sure.
//package.json
{
"name": "testapp",
"version": "0.0.0",
"description": "testapp",
"main": "index.js",
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"axios": "^0.9.1",
"babel-preset-stage-1": "^6.1.18",
"jquery": "^2.2.0",
"lodash": "^3.10.1",
"material-ui": "^0.14.4",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "^4.0.0",
"react-tap-event-plugin": "^0.2.2",
"redux": "^3.0.4",
"redux-promise": "^0.5.1"
}
}
.
//webpack.config
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};
推荐答案
我找到了解决方案.在 dependencies
对象中包含 "webpack": "^1.12.9"
.然后,改变
I found the solution. Include "webpack": "^1.12.9"
in the dependencies
object. Then, change
"scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js"
},
到
"scripts": {
"start": "node ./node_modules/webpack/bin/webpack.js"
},
这篇关于托管与 webpack 捆绑的 Web 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!