1 Star 0 Fork 0

黎明就在前方 / webpack教程配置版

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
package-lock.json 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
黎明就在前方 提交于 2018-11-12 16:24 . 新建 package-lock.json
const CleanWebpackPlugin = require('clean-webpack-plugin');
const htmlWebpackPlugin= require('html-webpack-plugin');
module.exports = {
devtool: 'eval-source-map',
//入口文件
entry: {
main: __dirname + "/app/main.js",
admin: __dirname + "/app/admin.js",
},
//出口文件
output: {
path: __dirname + "/dist",//打包后的文件存放的地方
filename: "assets/[name]-[hash].js",//打包后输出文件的文件名
publicPath: './',
},
devServer: {
contentBase: "./dist",//本地服务器所加载的页面所在的目录
historyApiFallback: true,//不跳转
inline: true,//实时刷新
port: 8081,
},
module: {
rules: [
{
test: /\.css$/, // https://www.webpackjs.com/loaders/css-loader/
use: [
{ loader: "style-loader" },
{ loader: "css-loader" },
// { loader: "postcss-loader" }
]
},
{
test: /\.less$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "less-loader" // compiles Less to CSS
}]
},
{
test: /\.js$/, // https://www.webpackjs.com/loaders/babel-loader/
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
//plugins: ['@babel/transform-runtime'] // 'transform-runtime' 插件告诉 babel 要引用 runtime 来代替注入。
}
}
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: [':data-src']
}
}
}
]
},
plugins: [
new htmlWebpackPlugin({
filename: "index.html",
template: 'index.html',
title: "入口文件一",
minify: {
//collapseWhitespace: true,
removeComments: true,
},
chunks: ["main"]
}),
new htmlWebpackPlugin({
filename: "admin.html",
template: 'index.html',
title: "入口文件二",
minify: {
//collapseWhitespace: true,
removeComments: true,
},
chunks: ["admin"]
}),
new CleanWebpackPlugin(['./dist/']),
]
}
//详细文档 https://www.webpackjs.com/
//loaders配置文档:https://www.webpackjs.com/loaders/
1
https://gitee.com/dmui/webpack_baseClass.git
git@gitee.com:dmui/webpack_baseClass.git
dmui
webpack_baseClass
webpack教程配置版
master

搜索帮助