代码拉取完成,页面将自动刷新
/*******************************************************************************
* Copyright 2020 huanggefan.cn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const IndexPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/index/index.html"),
filename: path.resolve(__dirname, "dist/index.html"),
chunks: ['api', 'style', 'index']
});
const StudentPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/index.html"),
filename: path.resolve(__dirname, "dist/student.html"),
chunks: ['api', 'style', 'student']
});
const StudentCoursePage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-course.html"),
filename: path.resolve(__dirname, "dist/student-course.html"),
chunks: ['api', 'style', 'student']
});
const StudentPracticePage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-practice.html"),
filename: path.resolve(__dirname, "dist/student-practice.html"),
chunks: ['api', 'style', 'student']
});
const StudentHomeworkPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-homework.html"),
filename: path.resolve(__dirname, "dist/student-homework.html"),
chunks: ['api', 'style', 'student']
});
const StudentExamPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-exam.html"),
filename: path.resolve(__dirname, "dist/student-exam.html"),
chunks: ['api', 'style', 'student']
});
const StudentDataPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-data.html"),
filename: path.resolve(__dirname, "dist/student-data.html"),
chunks: ['api', 'style', 'student']
});
const StudentCourseChaptersPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-course-chapters.html"),
filename: path.resolve(__dirname, "dist/student-course-chapters.html"),
chunks: ['api', 'style', 'student']
});
const StudentCourseContentPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/student/student-course-content.html"),
filename: path.resolve(__dirname, "dist/student-course-content.html"),
chunks: ['api', 'style', 'student']
});
const RootPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/root/index.html"),
filename: path.resolve(__dirname, "dist/root.html"),
chunks: ['api', 'style', 'root']
});
const ManagerPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/index.html"),
filename: path.resolve(__dirname, "dist/manager.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerCollegePage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-college.html"),
filename: path.resolve(__dirname, "dist/manager-college.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerMajorPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-major.html"),
filename: path.resolve(__dirname, "dist/manager-major.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerClassPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-class.html"),
filename: path.resolve(__dirname, "dist/manager-class.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerCoursePage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-course.html"),
filename: path.resolve(__dirname, "dist/manager-course.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerQuestionPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-question.html"),
filename: path.resolve(__dirname, "dist/manager-question.html"),
chunks: ['api', 'style', 'manager']
});
const ManagerUserPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/manager/manager-user.html"),
filename: path.resolve(__dirname, "dist/manager-user.html"),
chunks: ['api', 'style', 'manager']
});
const SettingPage = new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/pages/setting/index.html"),
filename: path.resolve(__dirname, "dist/setting.html"),
chunks: ['api', 'style', 'setting']
});
const devServerConf = {
contentBase: path.resolve(__dirname, "dist"),
inline: true,
host: "::",
port: 8000,
allowedHosts: ['*'],
useLocalIp: true,
compress: false,
index: "index.html",
publicPath: "/",
open: false,
stats: "errors-only",
hot: true
};
module.exports = {
entry: {
api: path.resolve(__dirname, "src/api/api.js"),
style: path.resolve(__dirname, "src/style/style.js"),
index: path.resolve(__dirname, "src/pages/index/index.js"),
student: path.resolve(__dirname, "src/pages/student/student.js"),
root: path.resolve(__dirname, "src/pages/root/root.js"),
manager: path.resolve(__dirname, "src/pages/manager/manager.js"),
setting: path.resolve(__dirname, "src/pages/setting/setting.js")
},
output: {
filename: "js/[name].[hash].js",
path: path.resolve(__dirname, "dist"),
publicPath: "/"
},
devServer: devServerConf,
stats: {
children: false
},
plugins: [
new MiniCssExtractPlugin({
filename: "css/[name].[hash].css",
chunkFilename: "css/[id].[hash].css"
}),
IndexPage,
StudentPage,
StudentCoursePage,
StudentPracticePage,
StudentHomeworkPage,
StudentExamPage,
StudentDataPage,
StudentCourseChaptersPage,
StudentCourseContentPage,
RootPage,
ManagerPage,
ManagerCollegePage,
ManagerMajorPage,
ManagerClassPage,
ManagerCoursePage,
ManagerQuestionPage,
ManagerUserPage,
SettingPage
],
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
attrs: ['img:src', 'link:href', 'script:src']
}
}
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
},
{
test: /\.(eot|woff|ttf|ico|png|svg|jpg)$/,
use: {
loader: 'url-loader',
options: {
name: '[name].[hash].[ext]',
outputPath: "assets",
publicPath: "/assets",
limit: 2048,
esModule: false
}
}
}
]
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。