diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js index b88485693c..12381d7079 100644 --- a/packages/config/src/config/build.js +++ b/packages/config/src/config/build.js @@ -48,6 +48,7 @@ export default () => ({ styleResources: {}, plugins: [], terser: {}, + hardSource: false, optimizeCSS: undefined, optimization: { runtimeChunk: 'single', diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 1cf63b8ddd..215520e6c3 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -24,6 +24,7 @@ "file-loader": "^2.0.0", "fs-extra": "^7.0.1", "glob": "^7.1.3", + "hard-source-webpack-plugin": "^0.13.1", "hash-sum": "^1.0.2", "html-webpack-plugin": "^3.2.0", "memory-fs": "^0.4.1", diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index 3193ab72a9..cf0100586e 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -6,6 +6,7 @@ import cloneDeep from 'lodash/cloneDeep' import escapeRegExp from 'lodash/escapeRegExp' import VueLoader from 'vue-loader' import ExtractCssChunks from 'extract-css-chunks-webpack-plugin' +import HardSourcePlugin from 'hard-source-webpack-plugin' import TerserWebpackPlugin from 'terser-webpack-plugin' import WebpackBar from 'webpackbar' import env from 'std-env' @@ -352,6 +353,10 @@ export default class WebpackBaseConfig { }, this.options.build.extractCSS))) } + if (this.options.build.hardSource) { + plugins.push(new HardSourcePlugin(Object.assign({}, this.options.build.hardSource))) + } + return plugins } diff --git a/yarn.lock b/yarn.lock index fa5bd57c74..4ea926cb0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5033,6 +5033,25 @@ har-validator@~5.1.0: ajv "^6.5.5" har-schema "^2.0.0" +hard-source-webpack-plugin@^0.13.1: + version "0.13.1" + resolved "https://registry.npmjs.org/hard-source-webpack-plugin/-/hard-source-webpack-plugin-0.13.1.tgz#a99071e25b232f1438a5bc3c99f10a3869e4428e" + integrity sha512-r9zf5Wq7IqJHdVAQsZ4OP+dcUSvoHqDMxJlIzaE2J0TZWn3UjMMrHqwDHR8Jr/pzPfG7XxSe36E7Y8QGNdtuAw== + dependencies: + chalk "^2.4.1" + find-cache-dir "^2.0.0" + graceful-fs "^4.1.11" + lodash "^4.15.0" + mkdirp "^0.5.1" + node-object-hash "^1.2.0" + parse-json "^4.0.0" + pkg-dir "^3.0.0" + rimraf "^2.6.2" + semver "^5.6.0" + tapable "^1.0.0-beta.5" + webpack-sources "^1.0.1" + write-json-file "^2.3.0" + has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -7372,6 +7391,11 @@ node-notifier@^5.2.1: shellwords "^0.1.1" which "^1.3.0" +node-object-hash@^1.2.0: + version "1.4.1" + resolved "https://registry.npmjs.org/node-object-hash/-/node-object-hash-1.4.1.tgz#de968492e20c493b8bbc25ad2ee828265fd60934" + integrity sha512-JQVqSM5/mOaUoUhCYR0t1vgm8RFo7qpJtPvnoFCLeqQh1xrfmr3BCD3nGBnACzpIEF7F7EVgqGD3O4lao/BY/A== + node-pre-gyp@^0.10.0: version "0.10.3" resolved "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" @@ -10422,6 +10446,11 @@ tapable@^1.0.0, tapable@^1.1.0: resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz#0d076a172e3d9ba088fd2272b2668fb8d194b78c" integrity sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA== +tapable@^1.0.0-beta.5: + version "1.1.1" + resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.1.tgz#4d297923c5a72a42360de2ab52dadfaaec00018e" + integrity sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA== + tar@^2.0.0: version "2.2.1" resolved "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" @@ -11181,7 +11210,7 @@ webpack-node-externals@^1.7.2: resolved "http://registry.npmjs.org/webpack-node-externals/-/webpack-node-externals-1.7.2.tgz#6e1ee79ac67c070402ba700ef033a9b8d52ac4e3" integrity sha512-ajerHZ+BJKeCLviLUUmnyd5B4RavLF76uv3cs6KNuO8W+HuQaEs0y0L7o40NQxdPy5w0pcv8Ew7yPUAQG0UdCg== -webpack-sources@^1.1.0, webpack-sources@^1.3.0: +webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz#2a28dcb9f1f45fe960d8f1493252b5ee6530fa85" integrity sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA==