From 7c817893d9c83eebff37674050cde07c361879e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E6=88=90?= Date: Mon, 16 Mar 2020 16:37:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20update=20webpack=20confi?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 43 +++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++- src/index.html | 12 ++++++++++++ src/polyfills.js | 2 ++ webpack.common.js | 10 ++++------ webpack.dev.js | 10 +++++++++- webpack.prod.js | 9 ++++++++- 7 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 src/polyfills.js diff --git a/package-lock.json b/package-lock.json index 6713b6c..2e2e912 100644 --- a/package-lock.json +++ b/package-lock.json @@ -820,6 +820,39 @@ } } }, + "babel-polyfill": { + "version": "6.26.0", + "resolved": "http://npm.devops.xiaohongshu.com:7001/babel-polyfill/download/babel-polyfill-6.26.0.tgz", + "integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=", + "requires": { + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "regenerator-runtime": "^0.10.5" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.10.5", + "resolved": "http://npm.devops.xiaohongshu.com:7001/regenerator-runtime/download/regenerator-runtime-0.10.5.tgz", + "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=" + } + } + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "http://npm.devops.xiaohongshu.com:7001/babel-runtime/download/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "http://npm.devops.xiaohongshu.com:7001/regenerator-runtime/download/regenerator-runtime-0.11.1.tgz", + "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "http://npm.devops.xiaohongshu.com:7001/balanced-match/download/balanced-match-1.0.0.tgz", @@ -1714,6 +1747,11 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, + "core-js": { + "version": "2.6.11", + "resolved": "http://npm.devops.xiaohongshu.com:7001/core-js/download/core-js-2.6.11.tgz", + "integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw=" + }, "core-util-is": { "version": "1.0.2", "resolved": "http://npm.devops.xiaohongshu.com:7001/core-util-is/download/core-util-is-1.0.2.tgz", @@ -9543,6 +9581,11 @@ "integrity": "sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=", "dev": true }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "http://npm.devops.xiaohongshu.com:7001/whatwg-fetch/download/whatwg-fetch-3.0.0.tgz", + "integrity": "sha1-/IBORYzEYACbGiuWa8iBfSV4rvs=" + }, "which": { "version": "1.3.1", "resolved": "http://npm.devops.xiaohongshu.com:7001/which/download/which-1.3.1.tgz", diff --git a/package.json b/package.json index e4a4a65..ef63668 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,9 @@ "webpack-merge": "^4.2.2" }, "dependencies": { - "lodash": "^4.17.15" + "babel-polyfill": "^6.26.0", + "lodash": "^4.17.15", + "whatwg-fetch": "^3.0.0" }, "sideEffects": [ "*.css" diff --git a/src/index.html b/src/index.html index 9695a39..38fa2ea 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,18 @@ vue project + diff --git a/src/polyfills.js b/src/polyfills.js new file mode 100644 index 0000000..b4a714f --- /dev/null +++ b/src/polyfills.js @@ -0,0 +1,2 @@ +import 'babel-polyfill'; +import 'whatwg-fetch'; diff --git a/webpack.common.js b/webpack.common.js index ec20244..1e755fc 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -6,12 +6,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: { index: './src/app.js', - }, - output: { - path: path.resolve(__dirname, 'dist'), - filename: '[name].[contenthash].js', - chunkFilename: '[name].[contenthash].js', - publicPath: '', + polyfills: './src/polyfills.js', }, target: 'web', plugins: [ @@ -25,6 +20,7 @@ module.exports = { }, extensions: ['.js', '*'], + symlinks: false, }, module: { rules: [ @@ -37,6 +33,7 @@ module.exports = { { test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }, { test: /\.(png|svg|jpg|jpeg|gif)$/, + include: path.resolve(__dirname, 'src'), use: [ { loader: 'url-loader', @@ -48,6 +45,7 @@ module.exports = { }, { test: /\.(woff|woff2|eot|ttf|otf)$/, + include: path.resolve(__dirname, 'src'), use: [ 'file-loader', ], diff --git a/webpack.dev.js b/webpack.dev.js index 497959e..dbdb065 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -4,6 +4,13 @@ const common = require('./webpack.common.js'); module.exports = merge(common, { mode: 'development', + output: { + path: path.resolve(__dirname, 'dist'), + filename: '[name].js', + chunkFilename: '[name].js', + publicPath: '', + pathinfo: false, + }, devServer: { contentBase: path.resolve(__dirname, 'dist'), compress: true, @@ -21,7 +28,8 @@ module.exports = merge(common, { { test: /\.css$/, exclude: /node_modules/, use: ['style-loader', 'css-loader'] }, ], }, - plugins: [], + plugins: [ + ], devtool: 'eval-source-map', performance: { hints: 'warning', diff --git a/webpack.prod.js b/webpack.prod.js index e423e70..5f2e0c4 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -1,5 +1,5 @@ const merge = require('webpack-merge'); -// const path = require('path'); +const path = require('path'); const TerserJSPlugin = require('terser-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); @@ -7,6 +7,13 @@ const common = require('./webpack.common.js'); module.exports = merge(common, { mode: 'production', + output: { + path: path.resolve(__dirname, 'dist'), + filename: '[name].[contenthash].js', + chunkFilename: '[name].[contenthash].js', + publicPath: '', + pathinfo: false, + }, optimization: { minimizer: [ new TerserJSPlugin({}),