Skip to content

Commit

Permalink
Update package name to webpack-config
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Feb 12, 2019
1 parent 3cd6ad3 commit eb7a325
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 179 deletions.
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,12 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/viewport/README.md",
"parent": "packages"
},
{
"title": "@wordpress/webpack-config",
"slug": "packages-webpack-config",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/webpack-config/README.md",
"parent": "packages"
},
{
"title": "@wordpress/wordcount",
"slug": "packages-wordcount",
Expand Down
59 changes: 46 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@wordpress/babel-plugin-makepot": "file:packages/babel-plugin-makepot",
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
"@wordpress/browserslist-config": "file:packages/browserslist-config",
"@wordpress/build-config": "file:packages/build-config",
"@wordpress/custom-templated-path-webpack-plugin": "file:packages/custom-templated-path-webpack-plugin",
"@wordpress/e2e-test-utils": "file:packages/e2e-test-utils",
"@wordpress/e2e-tests": "file:packages/e2e-tests",
Expand All @@ -72,6 +71,7 @@
"@wordpress/npm-package-json-lint-config": "file:packages/npm-package-json-lint-config",
"@wordpress/postcss-themes": "file:packages/postcss-themes",
"@wordpress/scripts": "file:packages/scripts",
"@wordpress/webpack-config": "file:packages/webpack-config",
"babel-loader": "8.0.0",
"benchmark": "2.1.4",
"browserslist": "4.4.1",
Expand Down Expand Up @@ -114,8 +114,6 @@
"source-map-loader": "0.2.3",
"stylelint-config-wordpress": "13.1.0",
"uuid": "3.3.2",
"webpack-bundle-analyzer": "3.0.2",
"webpack-livereload-plugin": "2.1.1",
"webpack-rtl-plugin": "github:yoavf/webpack-rtl-plugin#develop"
},
"npmPackageJsonLintConfig": {
Expand Down
2 changes: 0 additions & 2 deletions packages/build-config/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/build-config/index.js

This file was deleted.

88 changes: 0 additions & 88 deletions packages/build-config/package.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/webpack-config/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions packages/webpack-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 (Unreleased)

- Initial release.
13 changes: 13 additions & 0 deletions packages/webpack-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Webpack Config

[Webpack](https://webpack.js.org/) config for WordPress development.

## Installation

Install the module

```bash
npm install @wordpress/webpack-config --save-dev
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
/**
* External dependencies
*/
const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
const LiveReloadPlugin = require( 'webpack-livereload-plugin' );

const { get } = require( 'lodash' );
const { basename } = require( 'path' );

const { BundleAnalyzerPlugin } = require( 'webpack-bundle-analyzer' );

/**
* WordPress dependencies
*/
const CustomTemplatedPathPlugin = require( '@wordpress/custom-templated-path-webpack-plugin' );
const LibraryExportDefaultPlugin = require( '@wordpress/library-export-default-webpack-plugin' );

/**
* Given a string, returns a new string with dash separators converted to
* camelCase equivalent. This is not as aggressive as `_.camelCase` in
* converting to uppercase, where Lodash will also capitalize letters
* following numbers.
*
* @param {string} string Input dash-delimited string.
*
* @return {string} Camel-cased string.
*/
function camelCaseDash( string ) {
return string.replace(
/-([a-z])/g,
( match, letter ) => letter.toUpperCase()
);
}
const LiveReloadPlugin = require( 'webpack-livereload-plugin' );

/**
* Converts @wordpress require into window reference
Expand Down Expand Up @@ -67,8 +39,6 @@ const externals = [
jquery: 'jQuery',
lodash: 'lodash',
'lodash-es': 'lodash',
electron: 'electron',
wp: 'wp',
},
wordpressExternals,
];
Expand All @@ -87,7 +57,7 @@ const config = {
externals,
resolve: {
modules: [
__dirname,
process.cwd(),
'node_modules',
],
alias: {
Expand All @@ -113,40 +83,6 @@ const config = {
],
},
plugins: [
// Create RTL files with a -rtl suffix
new WebpackRTLPlugin( {
suffix: '-rtl',
minify: process.env.NODE_ENV === 'production' ? { safe: true } : false,
} ),
new CustomTemplatedPathPlugin( {
basename( path, data ) {
let rawRequest;

const entryModule = get( data, [ 'chunk', 'entryModule' ], {} );
switch ( entryModule.type ) {
case 'javascript/auto':
rawRequest = entryModule.rawRequest;
break;

case 'javascript/esm':
rawRequest = entryModule.rootModule.rawRequest;
break;
}

if ( rawRequest ) {
return basename( rawRequest );
}

return path;
},
} ),
new LibraryExportDefaultPlugin( [
'api-fetch',
'deprecated',
'dom-ready',
'redux-routine',
'token-list',
].map( camelCaseDash ) ),
// GUTENBERG_BUNDLE_ANALYZER global variable enables utility that represents bundle content
// as convenient interactive zoomable treemap.
process.env.GUTENBERG_BUNDLE_ANALYZER && new BundleAnalyzerPlugin(),
Expand Down
32 changes: 32 additions & 0 deletions packages/webpack-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@wordpress/webpack-config",
"version": "1.0.0-alpha.0",
"description": "Webpack config for WordPress development.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"webpack",
"config"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/webpack-config/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"engines": {
"node": ">=8",
"npm": ">=6.0.0"
},
"main": "index.js",
"dependencies": {
"webpack-bundle-analyzer": "^3.0.3",
"webpack-livereload-plugin": "^2.2.0"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit eb7a325

Please sign in to comment.