diff --git a/webmaker/package.json b/webmaker/package.json index 0ae44c6..4586aa2 100644 --- a/webmaker/package.json +++ b/webmaker/package.json @@ -1,64 +1,68 @@ { - "private": true, - "name": "webmaker", - "version": "0.0.0", - "license": "MIT", - "scripts": { - "start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev", - "build": "preact build", - "serve": "preact build && preact serve", - "dev": "preact watch", - "lint": "eslint src", - "test": "jest ./tests" - }, - "eslintConfig": { - "extends": "eslint-config-synacor" - }, - "eslintIgnore": [ - "build/*" - ], - "devDependencies": { - "eslint": "^4.9.0", - "eslint-config-synacor": "^2.0.2", - "identity-obj-proxy": "^3.0.0", - "if-env": "^1.0.0", - "jest": "^21.2.1", - "preact-cli": "^2.1.0", - "preact-render-spy": "^1.2.1" - }, - "dependencies": { - "@emmetio/codemirror-plugin": "^0.5.4", - "codemirror": "^5.37.0", - "copy-webpack-plugin": "^4.5.1", - "esprima": "^4.0.0", - "firebase": "^5.0.4", - "preact": "^8.2.6", - "preact-compat": "^3.17.0", - "preact-router": "^2.5.7", - "split.js": "^1.3.5" - }, - "jest": { - "verbose": true, - "setupFiles": [ - "/src/tests/__mocks__/browserMocks.js" - ], - "testURL": "http://localhost:8080", - "moduleFileExtensions": [ - "js", - "jsx" - ], - "moduleDirectories": [ - "node_modules" - ], - "moduleNameMapper": { - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/tests/__mocks__/fileMock.js", - "\\.(css|less|scss)$": "identity-obj-proxy", - "^./style$": "identity-obj-proxy", - "^preact$": "/node_modules/preact/dist/preact.min.js", - "^react$": "preact-compat", - "^react-dom$": "preact-compat", - "^create-react-class$": "preact-compat/lib/create-react-class", - "^react-addons-css-transition-group$": "preact-css-transition-group" - } - } + "private": true, + "name": "webmaker", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev", + "build": "preact build", + "serve": "preact build && preact serve", + "dev": "preact watch", + "lint": "eslint src", + "test": "jest ./tests" + }, + "eslintConfig": { + "extends": "eslint-config-synacor" + }, + "eslintIgnore": [ + "build/*" + ], + "devDependencies": { + "eslint": "^4.9.0", + "eslint-config-synacor": "^2.0.2", + "identity-obj-proxy": "^3.0.0", + "if-env": "^1.0.0", + "jest": "^21.2.1", + "preact-cli": "^2.1.0", + "preact-render-spy": "^1.2.1" + }, + "dependencies": { + "@emmetio/codemirror-plugin": "^0.5.4", + "codemirror": "^5.37.0", + "copy-webpack-plugin": "^4.5.1", + "esprima": "^4.0.0", + "firebase": "^5.0.4", + "preact": "^8.2.6", + "preact-compat": "^3.17.0", + "preact-router": "^2.5.7", + "split.js": "^1.3.5" + }, + "jest": { + "verbose": true, + "setupFiles": [ + "/src/tests/__mocks__/browserMocks.js" + ], + "testURL": "http://localhost:8080", + "moduleFileExtensions": [ + "js", + "jsx" + ], + "moduleDirectories": [ + "node_modules" + ], + "moduleNameMapper": { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/tests/__mocks__/fileMock.js", + "\\.(css|less|scss)$": "identity-obj-proxy", + "^./style$": "identity-obj-proxy", + "^preact$": "/node_modules/preact/dist/preact.min.js", + "^react$": "preact-compat", + "^react-dom$": "preact-compat", + "^create-react-class$": "preact-compat/lib/create-react-class", + "^react-addons-css-transition-group$": "preact-css-transition-group" + } + }, + "browserslist": [ + "last 3 Chrome versions", + "last 3 Firefox versions" + ] } diff --git a/webmaker/preact.config.js b/webmaker/preact.config.js index 7519206..9dcd9ad 100644 --- a/webmaker/preact.config.js +++ b/webmaker/preact.config.js @@ -1,4 +1,5 @@ import CopyWebpackPlugin from 'copy-webpack-plugin' +var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin'); /** * Function that mutates original webpack config. @@ -12,6 +13,15 @@ export default function (config, env, helpers) { if (env.isProd) { config.devtool = false; // disable sourcemaps + config.plugins.push( + new CommonsChunkPlugin({ + name: 'vendor', + minChunks: ({ + resource + }) => /node_modules/.test(resource), + }) + ); + config.plugins.push(new CopyWebpackPlugin([{ context: `${__dirname}/src/assets`, from: `*.*`