1 Star 0 Fork 0

地狱/blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.publish.config.js 2.34 KB
一键复制 编辑 原始数据 按行查看 历史
无名氏 提交于 2017-09-15 15:31 . 更新打包方式
const webpack=require("webpack");
const path = require('path');
const node_modules = path.resolve(__dirname, 'node_modules');
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlwebpackPlugin=require("html-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app:path.resolve(__dirname,'src/main.js'),
vue:['vue','vuex','vue-resource'],
element:['element-ui'],
mEditor:['mavon-editor']
},
output: {
path: path.resolve(__dirname, 'dist/app'),
filename: 'static/js/app_[name].js',
},
module: {
loaders: [
{
test:/\.vue$/,
loader:'vue-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'style-loader'
})
},
{
test:/\.js$/,
loader:'babel-loader',
exclude:/node_modules/,
query: {
presets: ['es2015']
}
},
{
test:/\.less$/,
loader:'style-loader!css-loader!autoprefixer-loader!less-loader'
},
{
test:/\.scss$/,
loader:'style-loader!css-loader!autoprefixer-loader!sass-loader'
},
{
 test: /\.(png|jpg|gif)$/,
         loader:'url-loader?limit=8192&name=./static/img/[name].[ext]'
},
{
 test: /\.(ttf|woff|svg|eot|woff2)$/,
         loader:'url-loader?limit=8192&name=./static/font/[name].[ext]'
}
]
},
plugins:[
new webpack.optimize.CommonsChunkPlugin({
name: ['vue','element','mEditor'],
filename: 'static/js/vendor.[name].js',
chunks: 4
}),
new UglifyJsPlugin({
compress:{
warnings:false
}
}),
new ExtractTextPlugin("static/css/styles.css"),
new HtmlwebpackPlugin({
title: 'index', //生成的页面标题
filename: 'index.html', //生成的文件名称
template: 'index.html' //根据index1.html这个模板来生成
}),
new CleanWebpackPlugin(
['dist/app/'],  //匹配删除的文件
{
root: __dirname,           //根目录
verbose: true,           //开启在控制台输出信息
dry: false           //启用删除文件
})
]
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/diyuzhe/blog.git
git@gitee.com:diyuzhe/blog.git
diyuzhe
blog
blog
master

搜索帮助