代码拉取完成,页面将自动刷新
var pkg = require("./package.json");
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");
var CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: {
app: path.resolve(__dirname, "examples/src/index.js"),
// 将 第三方依赖(node_modules中的) 单独打包
vendor: Object.keys(pkg.dependencies)
},
output: {
path: __dirname + "/docs",
filename: "[name].[chunkhash:8].js"
},
resolve: {
extensions: [".js", ".jsx"]
},
mode: "production",
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader"
}
]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: true }
}
]
},
{
test: /\.(png|svg|jpg|gif)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 10000,
mimetype: "image/png",
fallback: "responsive-loader"
}
}
]
},
{
test: /\.(woff|woff2|svg|tff|eot)()/i,
use: [
{
loader: "url-loader",
options: {
limit: 10000,
mimetype: "image/png",
fallback: "responsive-loader"
}
}
]
},
{
test: /\.scss|css$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
"css-loader",
"sass-loader"
]
}
]
},
plugins: [
// webpack 内置的 banner-plugin
new webpack.BannerPlugin("Copyright by wangfupeng1988@github.com."),
new CleanWebpackPlugin(["docs"]),
// html 模板插件
new HtmlWebpackPlugin({
template: __dirname + "/examples/index.html"
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
})
]
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。