Просмотр исходного кода

use mini-css-extract-plugin instead of extract-text-webpack-plugin

Yuki Takei 7 лет назад
Родитель
Сommit
3071c405a3
4 измененных файлов с 24 добавлено и 31 удалено
  1. 0 1
      config/webpack.common.js
  2. 7 9
      config/webpack.dev.js
  3. 15 19
      config/webpack.prod.js
  4. 2 2
      package.json

+ 0 - 1
config/webpack.common.js

@@ -104,7 +104,6 @@ module.exports = (options) => {
           test: /\.(sc|sa|c)ss$/,
           test: /\.(sc|sa|c)ss$/,
           use: ['style-loader', 'css-loader', 'sass-loader'],
           use: ['style-loader', 'css-loader', 'sass-loader'],
           exclude: [helpers.root('src/client')]
           exclude: [helpers.root('src/client')]
-
         },
         },
         /*
         /*
          * File loader for supporting images, for example, in CSS files.
          * File loader for supporting images, for example, in CSS files.

+ 7 - 9
config/webpack.dev.js

@@ -2,14 +2,13 @@
  * @author: Yuki Takei <yuki@weseek.co.jp>
  * @author: Yuki Takei <yuki@weseek.co.jp>
  */
  */
 
 
-const path = require('path');
 const webpack = require('webpack');
 const webpack = require('webpack');
 const helpers = require('../src/lib/util/helpers');
 const helpers = require('../src/lib/util/helpers');
 
 
 /*
 /*
  * Webpack Plugins
  * Webpack Plugins
  */
  */
-const ExtractTextPlugin = require('extract-text-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 
 
 /**
 /**
@@ -40,19 +39,18 @@ module.exports = require('./webpack.common')({
       },
       },
       { // Dump CSS for HackMD
       { // Dump CSS for HackMD
         test: /\.(sc|sa|c)ss$/,
         test: /\.(sc|sa|c)ss$/,
-        use: ExtractTextPlugin.extract({
-          use: [
-            'css-loader',
-            'sass-loader'
-          ]
-        }),
+        use: [
+          MiniCssExtractPlugin.loader,
+          'css-loader',
+          'sass-loader'
+        ],
         include: [helpers.root('src/client/styles/hackmd')]
         include: [helpers.root('src/client/styles/hackmd')]
       },
       },
     ],
     ],
   },
   },
   plugins: [
   plugins: [
 
 
-    new ExtractTextPlugin({
+    new MiniCssExtractPlugin({
       filename: '[name].bundle.css',
       filename: '[name].bundle.css',
     }),
     }),
 
 

+ 15 - 19
config/webpack.prod.js

@@ -6,8 +6,8 @@ const helpers = require('../src/lib/util/helpers');
 /**
 /**
  * Webpack Plugins
  * Webpack Plugins
  */
  */
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
-const ExtractTextPlugin = require('extract-text-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
 const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
 const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
 
 
@@ -27,25 +27,24 @@ module.exports = require('./webpack.common')({
     rules: [
     rules: [
       {
       {
         test: /\.(sc|sa|c)ss$/,
         test: /\.(sc|sa|c)ss$/,
-        use: ExtractTextPlugin.extract({
-          use: [
-            'css-loader',
-            { loader: 'postcss-loader', options: {
-              sourceMap: false,
-              plugins: (loader) => [
-                require('autoprefixer')()
-              ]
-            } },
-            'sass-loader'
-          ]
-        }),
+        use: [
+          MiniCssExtractPlugin.loader,
+          'css-loader',
+          { loader: 'postcss-loader', options: {
+            sourceMap: false,
+            plugins: (loader) => [
+              require('autoprefixer')()
+            ]
+          } },
+          'sass-loader'
+        ],
         include: [helpers.root('src/client')]
         include: [helpers.root('src/client')]
       }
       }
     ]
     ]
   },
   },
   plugins: [
   plugins: [
 
 
-    new ExtractTextPlugin({
+    new MiniCssExtractPlugin({
       filename: '[name].[hash].css',
       filename: '[name].[hash].css',
     }),
     }),
 
 
@@ -58,10 +57,7 @@ module.exports = require('./webpack.common')({
   ],
   ],
   optimization: {
   optimization: {
     minimizer: [
     minimizer: [
-      new UglifyJsPlugin({
-        cache: true,
-        parallel: true,
-      }),
+      new TerserPlugin({}),
       new OptimizeCSSAssetsPlugin({})
       new OptimizeCSSAssetsPlugin({})
     ],
     ],
   },
   },

+ 2 - 2
package.json

@@ -149,7 +149,6 @@
     "eazy-logger": "^3.0.2",
     "eazy-logger": "^3.0.2",
     "eslint": "^5.0.0",
     "eslint": "^5.0.0",
     "eslint-plugin-react": "^7.7.0",
     "eslint-plugin-react": "^7.7.0",
-    "extract-text-webpack-plugin": "^4.0.0-beta.0",
     "file-loader": "^2.0.0",
     "file-loader": "^2.0.0",
     "handsontable": "^6.0.1",
     "handsontable": "^6.0.1",
     "i18next-browser-languagedetector": "^2.2.0",
     "i18next-browser-languagedetector": "^2.2.0",
@@ -170,6 +169,7 @@
     "markdown-it-toc-and-anchor-with-slugid": "^1.1.4",
     "markdown-it-toc-and-anchor-with-slugid": "^1.1.4",
     "markdown-table": "^1.1.1",
     "markdown-table": "^1.1.1",
     "metismenu": "^3.0.3",
     "metismenu": "^3.0.3",
+    "mini-css-extract-plugin": "^0.5.0",
     "mocha": "^5.2.0",
     "mocha": "^5.2.0",
     "morgan": "^1.9.0",
     "morgan": "^1.9.0",
     "node-dev": "^3.1.3",
     "node-dev": "^3.1.3",
@@ -201,9 +201,9 @@
     "socket.io-client": "^2.0.3",
     "socket.io-client": "^2.0.3",
     "stream-to-promise": "^2.2.0",
     "stream-to-promise": "^2.2.0",
     "style-loader": "^0.23.0",
     "style-loader": "^0.23.0",
+    "terser-webpack-plugin": "^1.2.2",
     "throttle-debounce": "^2.0.0",
     "throttle-debounce": "^2.0.0",
     "toastr": "^2.1.2",
     "toastr": "^2.1.2",
-    "uglifyjs-webpack-plugin": "^2.0.1",
     "webpack": "^4.12.0",
     "webpack": "^4.12.0",
     "webpack-assets-manifest": "^3.0.1",
     "webpack-assets-manifest": "^3.0.1",
     "webpack-bundle-analyzer": "^3.0.2",
     "webpack-bundle-analyzer": "^3.0.2",