From 4d7fbc6ed4ada72d4b43f3477c55b6b1cda17ce9 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Wed, 17 Mar 2021 16:12:50 +0000 Subject: [PATCH] feat: update to webpack5 --- CHANGELOG.md | 6 -- CONTRIBUTING.md | 97 ----------------------- CoCreate.config.js | 6 +- package.json | 31 +++++--- src/{CoCreate-boilerplate.js => index.js} | 0 webpack.config.js | 90 ++++++++++++--------- 6 files changed, 75 insertions(+), 155 deletions(-) delete mode 100644 CHANGELOG.md delete mode 100644 CONTRIBUTING.md rename src/{CoCreate-boilerplate.js => index.js} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 94d6f23..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ -## [1.0.2](https://github.com/CoCreate-app/CoCreate-boilerplate/compare/v1.0.1...v1.0.2) (2021-02-02) - - -### Bug Fixes - -* (test) ([265f9d3](https://github.com/CoCreate-app/CoCreate-boilerplate/commit/265f9d331771da0c0eb2842dd1ffcad0dd0d9886)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c09a4fd..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,97 +0,0 @@ -# Contributing to CoCreate-boilerplate - -This project is work of [many contributors](https://github.com/CoCreate-app/CoCreate-boilerplate/graphs/contributors). -You're encouraged to submit [pull requests](https://github.com/CoCreate-app/CoCreate-boilerplate/pulls), -[propose features and discuss issues](https://github.com/CoCreate-app/CoCreate-boilerplate/issues). - -In the examples below, substitute your Github username for `contributor` in URLs. - -## Fork the Project - -Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-boilerplate) and check out your copy. - -``` -git boilerplate https://github.com/contributor/CoCreate-boilerplate.git -cd CoCreate-boilerplate -git remote add upstream https://github.com/CoCreate-app/CoCreate-boilerplate.git -``` - -## Create a Topic Branch - -Make sure your fork is up-to-date and create a topic branch for your feature or bug fix on dev branch. - -``` -git checkout dev -git pull upstream dev -git checkout -b my-feature-branch -``` - -## Write Tests - -Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. - -We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. - -## Write Code - -Implement your feature or bug fix. - -## Write Documentation - -Document any external behavior in the [README](README.md). - -## Commit Changes - -Make sure git knows your name and email address: - -``` -git config --global user.name "Your Name" -git config --global user.email "contributor@example.com" -``` - -We use [semantic-release](https://github.com/semantic-release/semantic-release) as process to generate changelog -and to release. Write meaningful commits according to -[Commit Message Formats](https://github.com/semantic-release/semantic-release#commit-message-format) is important. - -``` -git add ... -git commit -am "commit-type(optional topic): a meaningful message" -``` - -Here is an example of the release type that should be done based on a [semantic-release](https://github.com/semantic-release/semantic-release): - -| Commit message | Release type | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- | -| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release | -| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release | -| `perf(pencil): remove graphiteWidth option`

`BREAKING CHANGE: The graphiteWidth option has been removed.`
`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release | - - -## Push - -``` -git push origin my-feature-branch -``` - -## Make a Pull Request - -Go to [https://github.com/CoCreate-app/CoCreate-boilerplate](https://github.com/CoCreate-app/CoCreate-boilerplate) and select your feature branch. -Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. - -## Rebase - -If you've been working on a change for a while, rebase with upstream/dev. - -``` -git fetch upstream -git rebase upstream/dev -git push origin my-feature-branch -f -``` - -## Be Patient - -It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there! - -## Thank You - -Please do know that we really appreciate and value your time and work. We love you, really. \ No newline at end of file diff --git a/CoCreate.config.js b/CoCreate.config.js index 9c6d34d..5e34987 100644 --- a/CoCreate.config.js +++ b/CoCreate.config.js @@ -9,7 +9,7 @@ module.exports = { sources: [{ path: "./docs/index.html", collection: "files", - document_id: "6019b6c04eea0817df303b08", + document_id: "", key: "html", data:{ name: "boilerplate Doc", @@ -19,10 +19,10 @@ module.exports = { crud: [{ collection: "routes", - document_id: "6019b6c04eea0817df303b07", + document_id: "", data:{ collection: "files", - document_id: "6019b6c04eea0817df303b08", + document_id: "", name: "html", domains: ["cocreate.app", "server.cocreate.app", "ws.cocreate.app"], route: "/docs/boilerplate", diff --git a/package.json b/package.json index 8ed3240..b32b0cb 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,11 @@ "html5-framework", "javascript-framework" ], - "publishConfig": { - "access": "public" - }, + "publishConfig": { "access": "public" }, "scripts": { - "start": "npx webpack --config webpack.config.js --watch", + "start": "npx webpack --config webpack.config.js", "build": "NODE_ENV=production npx webpack --config webpack.config.js", + "dev": "npx webpack --config webpack.config.js --watch", "docs": "node ./node_modules/@cocreate/docs/src/index.js" }, "repository": { @@ -38,18 +37,24 @@ "url": "https://github.com/CoCreate-app/CoCreate-boilerplate/issues" }, "homepage": "https://cocreate.app/docs/boilerplate", + "funding": { + "type": "GitHub Sponsors ❤", + "url": "https://github.com/sponsors/CoCreate-app" + }, + "main": "./src/index.js", "devDependencies": { - "@babel/core": "^7.12.10", - "@babel/preset-env": "^7.12.11", - "babel-loader": "^8.2.2", + "@babel/core": "^7.9.6", + "@babel/preset-env": "^7.9.6", + "babel-loader": "^8.1.0", "clean-webpack-plugin": "^3.0.0", "html-webpack-plugin": "^4.5.0", "uglifyjs-webpack-plugin": "^2.2.0", - "webpack": "^5.14.0", - "webpack-cli": "^4.3.1", - "webpack-log": "^3.0.1" + "webpack": "^5.24.4", + "webpack-cli": "^4.5.0", + "webpack-log": "^3.0.1", + "file-loader": "^6.2.0", + "style-loader": "^2.0.0", + "terser-webpack-plugin": "^5.1.1" }, - "dependencies": { - "@cocreate/docs": "^1.0.3" - } + "dependencies": { "@cocreate/docs": "^1.0.3" } } diff --git a/src/CoCreate-boilerplate.js b/src/index.js similarity index 100% rename from src/CoCreate-boilerplate.js rename to src/index.js diff --git a/webpack.config.js b/webpack.config.js index ff98b83..843bac3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,61 +1,79 @@ -// Webpack uses this to work with directories -const path = require('path'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); -// const HtmlWebpackPlugin = require('html-webpack-plugin'); -// const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +const path = require("path") +const TerserPlugin = require("terser-webpack-plugin") -let isProduction = process.env.NODE_ENV === 'production'; +let isProduction = process.env.NODE_ENV === "production" +const { CleanWebpackPlugin } = require("clean-webpack-plugin") -// This is main configuration object. -// Here you write different options and tell Webpack what to do module.exports = { - - // Path to your entry point. From this file Webpack will begin his work entry: { - 'CoCreate-boilerplate': './src/CoCreate-boilerplate.js', + "CoCreate-boilerplate": "./src/index.js", }, - - // Path and filename of your result bundle. - // Webpack will bundle all JavaScript into this file output: { - path: path.resolve(__dirname, 'dist'), - filename: isProduction ? '[name].min.js' : '[name].js', - libraryTarget: 'umd', - libraryExport: 'default', - library: ['CoCreate', 'boilerplate'], + path: path.resolve(__dirname, "dist"), + filename: isProduction ? "[name].min.js" : "[name].js", + libraryTarget: "umd", + libraryExport: "default", + library: ["CoCreate", "boilerplate"], globalObject: "this", + publicPath: "https://server.cocreate.app/CoCreateJS/dist/", }, + plugins: [new CleanWebpackPlugin()], // Default mode for Webpack is production. // Depending on mode Webpack will apply different things // on final bundle. For now we don't need production's JavaScript // minifying and other thing so let's set mode to development - mode: isProduction ? 'production' : 'development', + mode: isProduction ? "production" : "development", module: { - rules: [{ - test: /\.js$/, + rules: [ + { + test: /.js$/, exclude: /(node_modules)/, use: { - loader: 'babel-loader', + loader: "babel-loader", options: { - presets: ['@babel/preset-env'] - } - } + plugins: ["@babel/plugin-transform-modules-commonjs"], + }, + }, }, - ] + { + test: /.css$/i, + use: [ + { loader: "style-loader", options: { injectType: "linkTag" } }, + "file-loader", + ], + }, + ], }, // add source map - ...(isProduction ? {} : { devtool: 'eval-source-map' }), + ...(isProduction ? {} : { devtool: "eval-source-map" }), - // add uglifyJs optimization: { - minimizer: [new UglifyJsPlugin({ - uglifyOptions: { - // get options: https://github.com/mishoo/UglifyJS - drop_console: isProduction + minimize: true, + minimizer: [ + new TerserPlugin({ + extractComments: true, + // cache: true, + parallel: true, + // sourceMap: true, // Must be set to true if using source-maps in production + terserOptions: { + // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions + // extractComments: 'all', + compress: { + drop_console: true, + }, + }, + }), + ], + splitChunks: { + chunks: "all", + minSize: 200, + // maxSize: 999999999, + //minChunks: 1, + cacheGroups: { + defaultVendors: false, }, - })], + }, }, - -}; +}