From 6191d2c1a097822175e3acfe87b80861141c3149 Mon Sep 17 00:00:00 2001 From: Baiang <973366510@qq.com> Date: Sun, 19 Aug 2018 12:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B0webpack4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/next.config.js | 26 +++++++++++++++++++++++++- package.json | 12 ++++++------ src/components/Footer.tsx | 2 +- src/components/Header.tsx | 2 +- src/index.tsx | 3 +-- src/pages/about.tsx | 2 +- src/pages/index.tsx | 2 +- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/config/next.config.js b/config/next.config.js index 02baf48..d06f0a2 100644 --- a/config/next.config.js +++ b/config/next.config.js @@ -11,7 +11,7 @@ const withLess = require('@zeit/next-less') const withCss = require('@zeit/next-css') const withSourceMaps = require('@zeit/next-source-maps') const conf = require('../config/config.global'); -const commonsChunkConfig = require('@zeit/next-css/commons-chunk-config') +// const commonsChunkConfig = require('@zeit/next-css/commons-chunk-config') const { ANALYZE } = process.env; @@ -19,6 +19,30 @@ const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; let isDev = true; +const commonsChunkConfig = (config, test = /\.css$/) => { + // Extend the default CommonsChunkPlugin config + config.plugins = config.plugins.map(plugin => { + if ( + plugin.constructor.name === 'CommonsChunkPlugin' && + typeof plugin.minChunks !== 'undefined' + ) { + const defaultMinChunks = plugin.minChunks + plugin.minChunks = (module, count) => { + // Move all styles to commons chunk so they can be extracted to a single file + if (module.resource && module.resource.match(test)) { + return true + } + // Use default minChunks for non-style modules + return typeof defaultMinChunks === 'function' + ? defaultMinChunks(module, count) + : count >= defaultMinChunks + } + } + return plugin + }) + return config +} + const nextConfig = { distDir: '../build', assetPrefix: conf[env].cdn, diff --git a/package.json b/package.json index f7a1040..14402fa 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "author": "wiwi", "license": "MIT", "dependencies": { - "@zeit/next-css": "^0.2.0", - "@zeit/next-sass": "^0.2.0", - "@zeit/next-less": "^0.3.0", - "@zeit/next-source-maps": "^0.0.2", - "@zeit/next-typescript": "^1.1.0", + "@zeit/next-css": "^0.2.1-canary.1", + "@zeit/next-less": "^0.3.1-canary.1", + "@zeit/next-sass": "^0.2.1-canary.1", + "@zeit/next-source-maps": "^0.0.3-canary.1", + "@zeit/next-typescript": "^1.1.1-canary.1", "antd": "^3.6.5", "next": "^7.0.0-canary.0", "node-sass": "^4.9.1", @@ -88,7 +88,7 @@ "ts-node": "^7.0.0", "typescript": "^2.9.2", "typescript-babel-jest": "^1.0.5", - "url-loader": "^1.0.1", + "url-loader": "^1.1.1", "webpack-bundle-analyzer": "^2.13.1", "webpack-bundle-size-analyzer": "^2.7.0" }, diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index ac05a7e..81a91c1 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -61,7 +61,7 @@ const Footer = () => {
上海睿渠网络技术有限公司 ©兜礼 沪ICP备15021038号
-