webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'assets/jsx/Index.jsx'),
output: {
path: path.resolve(__dirname, 'gae/src/static/build'),
filename: 'besetfree.js'
},
plugins: [
new webpack.NoErrorsPlugin()
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loaders: ['react-hot', 'babel?cacheDirectory,presets[]=react,presets[]=es2015']
},
{
test: /\.less$/,
loader: 'style!css!less'
}, // use ! to chain loaders
{
test: /\.css$/,
loader: 'style!css'
}
]
}
};
我运行这个npm命令:
"start": "webpack-dev-server --port 9898 --devtool eval --progress --colors --content-base gae/src --hot --inline",
它建立得很好:
> besetfree@1.0.0 start /Users/me/code/besetfree
> webpack-dev-server --port 9898 --devtool eval --progress --colors --content-base gae/src --hot --inline
70% 1/1 build moduleshttp://localhost:9898/
webpack result is served from /
content is served from /Users/me/code/besetfree/gae/src
Hash: 1abe8a20ea579ccbfa3a
Version: webpack 1.12.12
Time: 4361ms
Asset Size Chunks Chunk Names
besetfree.js 1.51 MB 0 [emitted] main
chunk {0} besetfree.js (main) 1.31 MB [rendered]
但http://localhost:9898/static/build/处没有文件:
请帮忙吗?
答案 0 :(得分:1)
您需要在Webpack配置中添加publicPath
,以便让服务器知道从哪个URL提供服务。
function setUp() {
document.getElementById("menu").onclick = setMenu;
}
function setMenu() {
var menuBox = document.getElementById("menu-box");
menuBox.className = "menuBox";
}
setUp();