第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么打包后,會有文件重復(fù)引用,使用的是webpack,好像和兩個入口文件有點關(guān)系,是哪里配置的不準確呢

https://img1.sycdn.imooc.com//5d24389e0001a6e407720167.jpg

const path = require("path"); //node js 基本包 處理路徑

const VueLoaderPlugin = require('vue-loader/lib/plugin');

const HtmlPlugin = require("html-webpack-plugin");

const webpack = require("webpack")

/* dev-serve[2][1] */

// 可能有用 extract-text-webpack-plugin 插件改成了 mini-css-extract-plugin

const isDev = process.env.NODE_ENV === "development";

const ExtractPlugin = require('extract-text-webpack-plugin')

const {

CleanWebpackPlugin

} = require('clean-webpack-plugin');

const config = {

/* dev-serve[1] target */

target: "web",

mode: 'production',

entry: {

app: path.join(__dirname, "src/index.js"),

vender: ['vue']

},

output: {

filename: "bundle.[hash:8].js",

path: path.join(__dirname, "dist")

},

resolve: {

extensions: ['.js', '.vue', '.json'],

alias: {

'vue$': 'vue/dist/vue.common' // 用 webpack 1 時需用 'vue/dist/vue.common.js'

}

},

module: {

rules: [{

test: /\.vue$/,

use: [ //使用use 完整寫法

{

loader: 'vue-loader',

},

]

}, {

test: /\.js$/,

loader: 'babel-loader'

}, {

test: /\.jsx$/,

loader: 'babel-loader'

},

/* ?{

? ? ? ? ? ? ? ? ? ? ? ?test: /\.css$/,

? ? ? ? ? ? ? ? ? ? ? ?use: ['vue-style-loader', 'style-loader', "css-loader"]

? ? ? ? ? ? ? ? ? ?} ,*/

{

test: /\.(gif|jpg|jepg|svg|png)$/,

use: [{

loader: "url-loader",

options: {

limit: 8192,

name: '[name]-aaa.[ext]'

}

}]

},

{

test: /\.styl/,

use: ExtractPlugin

.extract({

fallback: "style-loader",

use: [

"css-loader", {

loader: "postcss-loader",

options: {

sourceMap: true

}

}, "stylus-loader"

]

})

}

]

},

plugins: [

// make sure to include the plugin for the magic

new VueLoaderPlugin(),

new webpack.DefinePlugin({

'process.env': {

NODE_ENV: isDev ? '"development"' : '"production"'

}

}),

// new HtmlPlugin({

// ? ? filename: 'index.html',

// ? ? template: path.resolve(__dirname, 'index.html'),

// ? ? inject: true,/* 注入 */

// ? ? favicon:"./favicon.ico"

// }),

new HtmlPlugin({

title: '首頁',

template: path.resolve(__dirname, 'index.html'),

filename: 'index.html',

minify: true,

hash: false,

showErrors: true,

inject: true,

}),

new CleanWebpackPlugin(),

//webpacl 4.3 包含了 contenthash 關(guān)鍵字段 所以不能使用 contenthash 用md5:contenthash:hex:8 代替

// new ExtractPlugin("./styles.[contenthash:8].css")

new ExtractPlugin("./styles.[md5:contenthash:hex:8].css"),

//4棄用

// new webpack.optimize.CommonsChunkPlugin({

// ? ? name: "vender"

// })

// new webpack.optimize.SplitChunksPlugin({

// ? ? chunks: "all",

// ? ? name: true,

// ? ? cacheGroups: {

// ? ? ? ? vendors: {

// ? ? ? ? ? ? name: "vender",

// ? ? ? ? ? ? chunks: "all",

// ? ? ? ? ? ? minChunks: 2

// ? ? ? ? }

// ? ? }

// })

],

// devtool: "cheap-module-eval-source-map",

// devServer: {

// ? ? contentBase: path.join(__dirname, "dist"),

// ? ? compress: true,

// ? ? port: 9000,

// ? ? host: "0.0.0.0",

// ? ? hot: true,

// ? ? overlay: {

// ? ? ? ? warnings: true,

// ? ? ? ? errors: true,

// ? ? },

// },

performance: {

/* 如果一個資源超過 250kb,webpack 會對此輸出一個警告來通知你 */

hints: false


},

optimization: {

splitChunks: {

cacheGroups: {

vendor: {

name: "vendor",

chunks: "initial",

minChunks: 1

}

}

},

runtimeChunk: true

}

}

/* dev-serve[2] ?判斷一下 ? ?cross-env NODE_ENV=production*/

/* dev-serve[2][2] */

if (isDev) {

// config.devSever = {

// ? ? port: 8000,

// ? ? host: '0.0.0.0',

// ? ? /* 錯誤顯示在網(wǎng)頁上 */

// ? ? // overlay: {

// ? ? // ? ? "error": true,

// ? ? // }

// }


// config.module.rules.push({

// ? ? test: /\.styl/,

// ? ? use: [

// ? ? ? ? 'style-loader',

// ? ? ? ? "css-loader", {

// ? ? ? ? ? ? loader: "postcss-loader",

// ? ? ? ? ? ? options: {

// ? ? ? ? ? ? ? ? sourceMap: true

// ? ? ? ? ? ? }

// ? ? ? ? }, "stylus-loader"

// ? ? ]

// })



} else {

// config.output.filename = "[name].[chunkhash:8].js"

// config.module.rules({

// ? ? test: /\.styl/,

// ? ? use: ExtractPlugin

// ? ? ? ? .extract({

// ? ? ? ? ? ? fallback: "style-loader",

// ? ? ? ? ? ? use: [

// ? ? ? ? ? ? ? ? "css-loader", {

// ? ? ? ? ? ? ? ? ? ? loader: "postcss-loader",

// ? ? ? ? ? ? ? ? ? ? options: {

// ? ? ? ? ? ? ? ? ? ? ? ? sourceMap: true

// ? ? ? ? ? ? ? ? ? ? }

// ? ? ? ? ? ? ? ? }, "stylus-loader"

// ? ? ? ? ? ? ]

// ? ? ? ? })

// })

// config.plugins.push(

// ? ? new ExtractPlugin('styles.[contentHash:8].css')

// )

}

module.exports = config;


正在回答

1 回答

有代碼文件目錄的截圖嗎?方便定位問題

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么打包后,會有文件重復(fù)引用,使用的是webpack,好像和兩個入口文件有點關(guān)系,是哪里配置的不準確呢

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號