我是webpack的新手,并尝试探索如何在我的一些项目中使用它。我在我的本地项目中安装了webpack-hot-middleware,下面是webpack.config.js中的代码。 我运行webpack命令后它没有做任何事情,没有打开新的浏览器选项卡并显示网页,它没有显示终端中的任何错误。我在这里缺少什么?
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
entry: './dev/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader',
},
{
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
loader: 'url-loader'
}
]
},
plugins: [
new CopyWebpackPlugin([
{
from: './node_modules/bootstrap-sass/assets/fonts/bootstrap',
to: 'assets/fonts/bootstrap'
}
]),
new webpack.HotModuleReplacementPlugin()
]
};
终端输出:
Hash: e15c5a889e59610134b2
Version: webpack 3.4.1
Time: 3123ms
Asset Size Chunks Chunk Names
index.js 1.79 MB 0 [emitted] [big] main
index.js.map 2.24 MB 0 [emitted] main
assets/fonts/bootstrap/glyphicons-halflings-regular.eot 20.1 kB [emitted]
assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 18 kB [emitted]
assets/fonts/bootstrap/glyphicons-halflings-regular.woff 23.4 kB [emitted]
assets/fonts/bootstrap/glyphicons-halflings-regular.ttf 45.4 kB [emitted]
assets/fonts/bootstrap/glyphicons-halflings-regular.svg 109 kB [emitted]
[2] ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./dev/sass/style.scss 159 kB {0} [built]
[5] (webpack)/buildin/global.js 509 bytes {0} [built]
[6] (webpack)/buildin/module.js 517 bytes {0} [built]
[127] ./dev/index.js 94 bytes {0} [built]
[128] ./dev/sass/style.scss 1.15 kB {0} [built]
[132] ./dev/bootstrap.js 214 bytes {0} [built]
[136] ./node_modules/moment/locale ^\.\/.*$ 2.79 kB {0} [optional] [built]
[157] ./dev/app.js 13 bytes {0} [built]
+ 150 hidden modules