MOVE licence notices into their own file && OPTIMISE the dll by specifying a preset-env target

This commit is contained in:
Norbert de Langen 2018-11-28 16:05:19 +01:00
parent c46781863a
commit e7c24bae12
No known key found for this signature in database
GPG Key ID: 976651DA156C2825
4 changed files with 68 additions and 5 deletions

View File

@ -120,6 +120,10 @@ export default async function(options) {
response.set('Content-Type', 'text/javascript');
response.sendFile(path.join(`${dllPath}/${request.params[0]}`));
});
router.get(/\/sb_dll\/(.+\.LICENCE)$/, (request, response) => {
response.set('Content-Type', 'text/html');
response.sendFile(path.join(`${dllPath}/${request.params[0]}`));
});
router.get(/(.+\.js)$/, (request, response) => {
response.set('Content-Type', 'text/javascript');
response.sendFile(path.join(`${outputDir}/${request.params[0]}`));

View File

@ -1,11 +1,13 @@
import path from 'path';
import webpack from 'webpack';
// eslint-disable-next-line import/no-extraneous-dependencies
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
const resolveLocal = dir => path.join(__dirname, dir);
const r = resolveLocal('../../../node_modules');
const out = resolveLocal('../../core/dll');
export default ({ entry, provided = [] }) => ({
name: 'storybook-ui',
mode: 'production',
@ -27,7 +29,14 @@ export default ({ entry, provided = [] }) => ({
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { shippedProposals: true, modules: false }],
[
'@babel/preset-env',
{
shippedProposals: true,
modules: false,
targets: '> 0.25%, not dead',
},
],
'@babel/preset-react',
'@babel/preset-flow',
],
@ -43,12 +52,27 @@ export default ({ entry, provided = [] }) => ({
},
plugins: [
new webpack.ProgressPlugin(),
new webpack.DllPlugin({
context: r,
path: `${out}/[name]-manifest.json`,
name: '[name]_dll',
}),
],
optimization: {
concatenateModules: true,
portableRecords: true,
moduleIds: 'hashed',
minimizer: [
new UglifyJsPlugin({
extractComments: {
condition: /^\**!|@preserve|@license|@cc_on/i,
filename: file => file.replace('.js', '.LICENCE'),
banner: licenseFile => `License information can be found in ${licenseFile}`,
},
}),
],
},
performance: {
hints: false,
},

View File

@ -65,10 +65,10 @@
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-emotion": "^9.2.11",
"babel-plugin-macros": "^2.4.2",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-preset-vue": "^2.0.2",
"chalk": "^2.4.1",
"codecov": "^3.1.0",
@ -122,7 +122,8 @@
"tslint": "~5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.1.6"
"typescript": "^3.1.6",
"uglifyjs-webpack-plugin": "^2.0.1"
},
"husky": {
"hooks": {

View File

@ -5967,6 +5967,26 @@ cacache@^11.0.1, cacache@^11.0.2:
unique-filename "^1.1.0"
y18n "^4.0.0"
cacache@^11.2.0:
version "11.3.1"
resolved "https://registry.yarnpkg.com/cacache/-/cacache-11.3.1.tgz#d09d25f6c4aca7a6d305d141ae332613aa1d515f"
integrity sha512-2PEw4cRRDu+iQvBTTuttQifacYjLPhET+SYO/gEFMy8uhi+jlJREDAjSF5FWSdV/Aw5h18caHA7vMTw2c+wDzA==
dependencies:
bluebird "^3.5.1"
chownr "^1.0.1"
figgy-pudding "^3.1.0"
glob "^7.1.2"
graceful-fs "^4.1.11"
lru-cache "^4.1.3"
mississippi "^3.0.0"
mkdirp "^0.5.1"
move-concurrently "^1.0.1"
promise-inflight "^1.0.1"
rimraf "^2.6.2"
ssri "^6.0.0"
unique-filename "^1.1.0"
y18n "^4.0.0"
cache-base@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
@ -22264,7 +22284,7 @@ uglify-es@^3.1.9, uglify-es@^3.3.4:
commander "~2.13.0"
source-map "~0.6.1"
uglify-js@3.4.x, uglify-js@^3.1.4, uglify-js@^3.4.0:
uglify-js@3.4.x, uglify-js@^3.0.0, uglify-js@^3.1.4, uglify-js@^3.4.0:
version "3.4.9"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==
@ -22286,6 +22306,20 @@ uglifyjs-webpack-plugin@^1.2.4:
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
uglifyjs-webpack-plugin@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-2.0.1.tgz#f346af53ed496ce72fef462517d417f62bec3010"
integrity sha512-1HhCHkOB6wRCcv7htcz1QRPVbWPEY074RP9vzt/X0LF4xXm9l4YGd0qja7z88abDixQlnVwBjXsTBs+Xsn/eeQ==
dependencies:
cacache "^11.2.0"
find-cache-dir "^2.0.0"
schema-utils "^1.0.0"
serialize-javascript "^1.4.0"
source-map "^0.6.1"
uglify-js "^3.0.0"
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
uid-number@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"