瀏覽代碼

add some reposity

night-cherry 3 周之前
父節點
當前提交
a5532e654a
共有 1 個文件被更改,包括 16 次插入1 次删除
  1. 16 1
      webpack.config.js

+ 16 - 1
webpack.config.js

@@ -4,6 +4,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
 const HtmlWebpackPlugin = require('html-webpack-plugin');
 //const { VueLoaderPlugin } = require('vue-loader/dist/index');
 const { VueLoaderPlugin } = require('vue-loader');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 
 
 module.exports={
@@ -40,7 +41,17 @@ module.exports={
       },
       {
         test:/\.css$/i,
-        use:["style-loader","css-loader"],
+        // use:["style-loader","css-loader"],
+        use: [
+          MiniCssExtractPlugin.loader,
+          {
+            loader: 'css-loader',
+            options: {
+              // 重点:将 CSS 输出到对应入口的 css 目录
+              outputPath: '[name]/css/'  
+            }
+          }
+        ]
       },
      {
       test:/\.vue$/,
@@ -100,6 +111,10 @@ module.exports={
       filename:"index.html",
       chunks:['index'],
     }),
+    new MiniCssExtractPlugin({
+      // CSS 输出到对应入口的 css 目录
+      filename: '[name]/css/[name].[contenthash:8].css'  
+    })
   ],
   // 优化配置(如代码拆分)
   optimization: {