Webpack 编译但 webpack-dev-server 不具有相同的配置
Webpack compiles but webpack-dev-server does not with same config
我开始学习 webpack 并尝试使用 webpack-dev-server 进行编译和浏览器重新加载。
我 运行 遇到一个问题,当我 运行 命令时:
webpack
我的文件编译正常,但是当我使用命令时:
# I removed the "--hot" and "--inline" to try to isolate where the problem
# was coming from.
webpack-dev-server --config webpack.config.js
命令终端中的输出看起来不错,但实际上没有编译:
事实是,webpack-dev-server 确实 成功地提供了 public
目录中的文件,因此该部分正在工作,只是没有编译 javascript 和 vue 文件。
这是我的 webpack.config.js
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/public',
publicPath: '/public',
filename: 'bundle.js'
},
devtool: 'source-map',
devServer:{
contentBase: __dirname + '/public'
},
module:{
loaders:[
{ test: /\.vue$/, loader: 'vue'}
]
}
};
我一直在关注描述过程的 vue-loader start tutorial,我没有发现任何不妥之处。
我知道我指定的内容目录与教程不同,但据我所知这不会影响文件的编译。
我在这里错过了什么?
发生这种情况是因为 Webpack-dev-server 从内存而不是磁盘提供文件。
文档中的确切引用,https://webpack.github.io/docs/webpack-dev-server.html
This modified bundle is served from memory at the relative path
specified in publicPath (see API). It will not be written to your
configured output directory. Where a bundle already exists at the same
url path the bundle in memory will take precedence (by default).
我开始学习 webpack 并尝试使用 webpack-dev-server 进行编译和浏览器重新加载。
我 运行 遇到一个问题,当我 运行 命令时:
webpack
我的文件编译正常,但是当我使用命令时:
# I removed the "--hot" and "--inline" to try to isolate where the problem
# was coming from.
webpack-dev-server --config webpack.config.js
命令终端中的输出看起来不错,但实际上没有编译:
事实是,webpack-dev-server 确实 成功地提供了 public
目录中的文件,因此该部分正在工作,只是没有编译 javascript 和 vue 文件。
这是我的 webpack.config.js
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/public',
publicPath: '/public',
filename: 'bundle.js'
},
devtool: 'source-map',
devServer:{
contentBase: __dirname + '/public'
},
module:{
loaders:[
{ test: /\.vue$/, loader: 'vue'}
]
}
};
我一直在关注描述过程的 vue-loader start tutorial,我没有发现任何不妥之处。
我知道我指定的内容目录与教程不同,但据我所知这不会影响文件的编译。
我在这里错过了什么?
发生这种情况是因为 Webpack-dev-server 从内存而不是磁盘提供文件。 文档中的确切引用,https://webpack.github.io/docs/webpack-dev-server.html
This modified bundle is served from memory at the relative path specified in publicPath (see API). It will not be written to your configured output directory. Where a bundle already exists at the same url path the bundle in memory will take precedence (by default).