Feat dev3

This commit is contained in:
shunfa.xu 2020-05-25 00:59:46 +08:00
parent 6db0f29afa
commit 593c3dce79
4 changed files with 27 additions and 62 deletions

View File

@ -3,13 +3,7 @@ const config = require('./webpack.prod.conf');
webpack(config, (err, stats) => { webpack(config, (err, stats) => {
if (err || stats.hasErrors()) { if (err || stats.hasErrors()) {
// 在这里处理错误 console.error(err); // 错误打印
console.error(err);
return; return;
} }
// 处理完成 });
console.log(stats.toString({
chunks: false, // 使构建过程更静默无输出
colors: true // 在控制台展示颜色
}));
});

View File

@ -1,25 +1,20 @@
const path = require('path'); const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const AutoDllPlugin = require('autodll-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin'); const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = { module.exports = {
entry: { entry: {
bundle: path.resolve(__dirname, '../src/index.js') bundle: path.resolve(__dirname, '../src/index.js')
}, },
output: { output: {
path: path.resolve(__dirname, '../dist'), path: path.resolve(__dirname, '../dist'),
filename: '[name].[hash].js' filename: '[name].[hash].js'
}, },
resolve: { resolve: {
extensions: ['*', '.js', '.json', '.vue'], extensions: ['*', '.js', '.json', '.vue'],
alias: { },
'vue$': 'vue/dist/vue.esm.js', module: {
'@': path.resolve(__dirname, '../src'), rules: [
}
},
module: {
rules: [
{ {
test: /\.vue$/, test: /\.vue$/,
loader: 'vue-loader' loader: 'vue-loader'
@ -29,27 +24,12 @@ module.exports = {
use: 'babel-loader', use: 'babel-loader',
exclude: /node_modules/ exclude: /node_modules/
}, },
{ ]
test: /\.css$/, },
use: ['vue-style-loader', 'css-loader'] plugins: [
} new HtmlWebpackPlugin({
] template: path.resolve(__dirname, '../index.html')
}, }),
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../index.html')
}),
// Dll 优化,需要的时候可以打开
// new AutoDllPlugin({
// inject: true, // will inject the DLL bundle to index.html
// debug: true,
// filename: '[name]_[hash].js',
// path: './dll',
// entry: {
// vendor: ['vue', 'vue-router']
// }
// }),
new VueLoaderPlugin(), new VueLoaderPlugin(),
// new webpack.optimize.SplitChunksPlugin() ]
] };
};

View File

@ -6,15 +6,12 @@ module.exports = merge(baseConfig, {
mode: "development", mode: "development",
devtool: "inline-source-map", devtool: "inline-source-map",
module: { module: {
rules: [ // 自己拓展着玩呀 rules: [ // 自己拓展着玩呀
// {
// test: /\.css$/,
// use: ["vue-style-loader", "css-loader", "postcss-loader"],
// },
], ],
}, },
devServer: { devServer: {
contentBase: path.resolve(__dirname, "../dist"), contentBase: path.resolve(__dirname, "../dist"),
open: true, open: true,
}, },
}); });

View File

@ -8,13 +8,7 @@ module.exports = merge(baseConfig, {
devtool: "source-map", devtool: "source-map",
module: { module: {
rules: [ // 自己拓展着玩呀 rules: [ // 自己拓展着玩呀
// {
// test: /\.css$/,
// use: [
// 'css-loader',
// 'postcss-loader',
// ]
// },
], ],
}, },
plugins: [ plugins: [
@ -24,4 +18,4 @@ module.exports = merge(baseConfig, {
dry: false, dry: false,
}), }),
], ],
}); });