diff --git a/README.md b/README.md index 229174fb8..3a56c63f5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## Project npm scope -> `@wpw` +> `@wpackio` ## πŸš§πŸ‘€This is just a preface and under development. Watch out!πŸ‘€πŸš§ diff --git a/babel.config.js b/babel.config.js index 1e4d329ed..9945f46b2 100644 --- a/babel.config.js +++ b/babel.config.js @@ -7,7 +7,7 @@ module.exports = api => { targets: { node: '8.9.0', }, - modules: 'commonjs', + modules: 'cjs', }, ], ]; diff --git a/packages/scripts/.npmignore b/packages/scripts/.npmignore new file mode 100644 index 000000000..e771d2c9f --- /dev/null +++ b/packages/scripts/.npmignore @@ -0,0 +1,34 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +node_modules +*.un~ +yarn.lock +src +flow-typed +coverage +decls +examples diff --git a/packages/scripts/PREFACE.md b/packages/scripts/PREFACE.md new file mode 100644 index 000000000..5175bc642 --- /dev/null +++ b/packages/scripts/PREFACE.md @@ -0,0 +1,88 @@ +## Things it need to do + +- Load project config file from cli --project-config or `wpw.project.config.js` (if present) `process.cwd`. +- Load environment config file from cli --server-config or `wpw.dev.config.js` (if present) from `process.cwd`. +- DO NOT RELY ON `process.env.NODE_ENV`. Rather set it automatically depending on cli commands. + - `start` - Start browsersync sever with webpack middleware. + - `build` - Compile files. + - `init` - Create a `wpw.dev.config.js` through asking some questions (only if the file is not present). +- Also set `process.env.BABEL_ENV` so that `babel-loader` can play nice, (especially with the preset-react). + +## Structure `wpw.project.config.js` + +```js +module.exports = { + // Files we need to compile, and where to put + files: [ + // If this has length === 1, then single compiler + { + entry: { + // stuff + }, + filename: '[name].js', + path: path.resolve(__dirname, 'dist'), + }, + // If has more length, then multi-compiler + ], + // Project specific config + // Needs react? + hasReact: true, + // Needs sass? + hasSass: true, + // Externals + externals: { + jquery: 'jQuery', + }, + // Show overlay on development + errorOverlay: true, + // Auto optimization by webpack + // Split all common chunks with default config + // + // Won't hurt because we use PHP to automate loading + optimizeSplitChunks: true, + // Extra webpack config to be passed directly + webpackConfig: false, +}; +``` + +## Draft + +Possible `package.json` + +```json +{ + "name": "@wpw/scripts", + "version": "0.0.0", + "description": "@wpws/scripts is a single dependency for using WordPress webpack script.", + "main": "index.js", + "repository": "https://github.com/swashata/wp-webpack-script", + "author": "Swashata Ghosh", + "license": "MIT", + "private": false, + "dependencies": { + "@babel/core": "^7.1.0", + "@babel/plugin-proposal-class-properties": "^7.1.0", + "@babel/plugin-proposal-object-rest-spread": "^7.0.0", + "@babel/preset-env": "^7.1.0", + "@babel/preset-react": "^7.0.0", + "autoprefixer": "^9.1.5", + "babel-loader": "^8.0.2", + "browser-sync": "^2.24.7", + "clean-webpack-plugin": "^0.1.19", + "cross-env": "^5.2.0", + "css-loader": "^1.0.0", + "mini-css-extract-plugin": "^0.4.3", + "optimize-css-assets-webpack-plugin": "^5.0.1", + "postcss-loader": "^3.0.0", + "sass-loader": "^7.1.0", + "style-loader": "^0.23.0", + "uglifyjs-webpack-plugin": "^2.0.1", + "webpack": "^4.19.1", + "webpack-dev-middleware": "^3.3.0", + "webpack-hot-middleware": "^2.24.0" + }, + "publishConfig": { + "access": "public" + } +} +``` diff --git a/packages/scripts/README.md b/packages/scripts/README.md index 55929b843..b29da91ee 100644 --- a/packages/scripts/README.md +++ b/packages/scripts/README.md @@ -1,41 +1,39 @@ -## Draft - -Possible `package.json` - -```json -{ - "name": "@wpw/scripts", - "version": "0.0.0", - "description": "@wpws/scripts is a single dependency for using WordPress webpack script.", - "main": "index.js", - "repository": "https://github.com/swashata/wp-webpack-script", - "author": "Swashata Ghosh", - "license": "MIT", - "private": false, - "dependencies": { - "@babel/core": "^7.1.0", - "@babel/plugin-proposal-class-properties": "^7.1.0", - "@babel/plugin-proposal-object-rest-spread": "^7.0.0", - "@babel/preset-env": "^7.1.0", - "@babel/preset-react": "^7.0.0", - "autoprefixer": "^9.1.5", - "babel-loader": "^8.0.2", - "browser-sync": "^2.24.7", - "clean-webpack-plugin": "^0.1.19", - "cross-env": "^5.2.0", - "css-loader": "^1.0.0", - "mini-css-extract-plugin": "^0.4.3", - "optimize-css-assets-webpack-plugin": "^5.0.1", - "postcss-loader": "^3.0.0", - "sass-loader": "^7.1.0", - "style-loader": "^0.23.0", - "uglifyjs-webpack-plugin": "^2.0.1", - "webpack": "^4.19.1", - "webpack-dev-middleware": "^3.3.0", - "webpack-hot-middleware": "^2.24.0" - }, - "publishConfig": { - "access": "public" - } -} +# `@wpw/scripts` + +Stub README + +// TODO +> Intro + +## Installation + +If using `yarn` + +```bash +yarn add @wpw/scripts +``` + +or with `npm` + +```bash +npm i @wpw/scripts ``` + +## Usage + +// TODO +> Usage instruction + +## Configuration + +// TODO +> Configuration instruction + +## Development + +This package has the same `npm scripts` as this monorepo. These should be run +using `lerna run