代码拉取完成,页面将自动刷新
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 //启用删除文件
})
]
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。