1 Star 0 Fork 0

轻飘yyf/Template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.js 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
vladtsiukin 提交于 2020-04-13 21:54 . fix: mode
/* webpack.config.js */
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== 'production';
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: 'development',
node: {
Buffer: false,
process: false
},
watch: true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000,
ignored: /node_modules/
},
devtool: false, //devtool: 'eval', // Enable to debug js code
entry: {
app: [
'./src/index.js',
'./src/style/main.scss'
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: devMode ? '[name].js' : '[name].[chunkhash].js',
},
plugins: [
new CleanWebpackPlugin({
verbose: true,
cleanAfterEveryBuildPatterns: ['!index.html'],
}
),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].[contenthash].css',
chunkFilename: devMode ? '[id].css' : '[id].[contenthash].css',
}),
new HtmlWebpackPlugin({
inject: true,
hash: true,
template: './src/index.html',
filename: 'index.html'
})
],
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader", // enable eslint
options: {
fix: true
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.s?[ac]ss$/,
use: [ 'style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}
]
}
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yyf994/Template.git
git@gitee.com:yyf994/Template.git
yyf994
Template
Template
master

搜索帮助