瀏覽代碼

Build improvemnets

* Remove CleanWebpackPlugin
    This pugin would wipe the non-minified files every time `make dist` was called,
    and generally made it more difficult to build only particular files.
* Use order-only prerequisites for the `dist` Make recipe
    This allows more efficient building because order-only prerequisites
    don't force a rebuild of the main recipe.
    https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types
JC Brand 4 年之前
父節點
當前提交
fc2a0d07ab
共有 3 個文件被更改,包括 23 次插入26 次删除
  1. 2 2
      Makefile
  2. 0 1
      package.json
  3. 21 23
      webpack.prod.js

+ 2 - 2
Makefile

@@ -175,8 +175,8 @@ logo/conversejs-filled%.png:: logo/conversejs-filled.svg
 src/headless/dist/converse-headless.min.js: src webpack.common.js node_modules @converse/headless
 	npm run headless
 
-dist:: node_modules src/*
-	npm run dev && npm run build && make dist/website.css && make dist/website.min.css
+dist:: node_modules src/* | dist/converse.js dist/converse.css dist/website.css dist/website.min.css
+	npm run prod
 
 .PHONY: install
 install:: dist

+ 0 - 1
package.json

@@ -71,7 +71,6 @@
     "bootstrap.native": "^2.0.27",
     "bootstrap.native-loader": "2.0.0",
     "clean-css-cli": "^4.3.0",
-    "clean-webpack-plugin": "^3.0.0",
     "copy-webpack-plugin": "^6.0.2",
     "css-loader": "^3.5.3",
     "dayjs": "1.8.30",

+ 21 - 23
webpack.prod.js

@@ -5,36 +5,34 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const common = require("./webpack.common.js");
 const path = require('path');
 const webpack = require('webpack');
-const { CleanWebpackPlugin } = require('clean-webpack-plugin');
 const { merge}  = require("webpack-merge");
 
+const plugins = [
+    new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
+    new CopyWebpackPlugin({
+        patterns: [
+            {from: 'src/headless/node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
+            {from: 'sounds', to: 'sounds'},
+            {from: 'images/favicon.ico', to: 'images/favicon.ico'},
+            {from: 'images/custom_emojis', to: 'images/custom_emojis'},
+            {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
+            {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
+            {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
+            {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
+            {from: 'sass/webfonts', to: 'webfonts'}
+        ]
+    }),
+    new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
+        'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
+    })
+];
+
 module.exports = merge(common, {
+    plugins,
     output: {
         publicPath: ASSET_PATH,
         filename: 'converse.min.js',
     },
-    plugins: [
-        new CleanWebpackPlugin({
-            cleanStaleWebpackAssets: false // resolves conflict with CopyWebpackPlugin
-        }),
-        new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
-        new CopyWebpackPlugin({
-            patterns: [
-                {from: 'src/headless/node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
-                {from: 'sounds', to: 'sounds'},
-                {from: 'images/favicon.ico', to: 'images/favicon.ico'},
-                {from: 'images/custom_emojis', to: 'images/custom_emojis'},
-                {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
-                {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
-                {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
-                {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
-                {from: 'sass/webfonts', to: 'webfonts'}
-            ]
-        }),
-        new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
-            'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
-        })
-    ],
     mode: "production",
     devtool: "source-map",
     module: {