代码拉取完成,页面将自动刷新
const path = require('path');
// const webpack = require('webpack');
// const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const srcPath = path.resolve(__dirname, 'src');
const dir = {
js: `${srcPath}/scripts`,
style: `${srcPath}/styles`,
imgs: `${srcPath}/images`,
};
module.exports = {
entry: {
index: [
`${dir.js}/index.js`,
],
},
externals: {
jquery: 'jQuery',
},
plugins: [
new CopyWebpackPlugin([{
from: `${dir.js}/json`,
to: './json',
}]),
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
template: `${srcPath}/index.html`,
favicon: `${dir.imgs}/favicon.png`,
minify: {
collapseWhitespace: true,
removeComments: true,
},
}),
new ExtractTextPlugin({
filename: '[name].[contenthash].css',
}),
],
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
}),
// use: [
// 'style-loader',
// 'css-loader',
// 'sass-loader',
// ],
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.(png|jpg|svg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 8192,
},
},
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
},
},
],
},
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。