Skip to content

Commit

Permalink
feat: new plugin api with integrated HMR loader (#146)
Browse files Browse the repository at this point in the history
* feat: major rewrite of hot loader

BREAKING CHANGE: New loader API and options.

* fix: fixed package.json and lock files

* docs: updating readme and fixing plugin namespaces
  • Loading branch information
ScriptedAlchemy committed Mar 4, 2019
1 parent 048643a commit fd6d288
Show file tree
Hide file tree
Showing 43 changed files with 17,596 additions and 1,596 deletions.
68 changes: 31 additions & 37 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"presets": [
[
"env",
{
"useBuiltIns": true,
"targets": {
"node": "6.9.0"
},
"exclude": [
"transform-async-to-generator",
"transform-regenerator"
]
}
"presets": [
[
"env",
{
"useBuiltIns": true,
"targets": {
"node": "6.9.0"
},
"exclude": [
"transform-async-to-generator",
"transform-regenerator"
]
],
"plugins": [
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
],
"transform-es2015-block-scoping",
"transform-es2015-arrow-functions",
"transform-es2015-template-literals"
],
"env": {
"test": {
"presets": [
"env"
],
"plugins": [
"transform-object-rest-spread",
"transform-es2015-block-scoping",
"transform-es2015-arrow-functions",
"transform-es2015-template-literals"
]
}
}
]
],
"plugins": [
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]
],
"env": {
"test": {
"presets": [
"env"
],
"plugins": [
"transform-object-rest-spread"
]
}
}
}
18 changes: 7 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# EditorConfig is awesome: http://EditorConfig.org
# editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
test/js/**/*.js
/node_modules
/dist
/test/cases
/test/js
/test/manual
25 changes: 11 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
module.exports = {
root: true,
plugins: ['prettier'],
extends: ['@webpack-contrib/eslint-config-webpack'],
globals: {
document: true
},
rules: {
'prettier/prettier': [
'error',
{ singleQuote: true, trailingComma: 'es5', arrowParens: 'always' },
],
'class-methods-use-this': 'off',
'no-undefined': 'off',
},
root: true,
plugins: ['prettier'],
extends: ['@webpack-contrib/eslint-config-webpack'],
rules: {
'prettier/prettier': [
'error',
{ singleQuote: true, trailingComma: 'es5', arrowParens: 'always' },
],
'class-methods-use-this': 'off',
'no-undefined': 'off',
},
};
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
package-lock.json -diff
* text=auto
test/cases/* eol=lf
bin/* eol=lf
23 changes: 14 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
/node_modules

/test/js
logs
*.log
npm-debug.log*
.eslintcache
/coverage
/dist

.idea
.eslintcache

/test/js
/local
/reports
/node_modules
.DS_Store
*.log
.eslintcache
Thumbs.db
.idea
.vscode
*.sublime-project
*.sublime-workspace
.idea
21 changes: 0 additions & 21 deletions CHANGELOG.md

This file was deleted.

30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ module.exports = {
{
test: /\.css$/,
use: [
ExtractCssChunks.loader,
{
loader:ExtractCssChunks.loader,
options: {
hot: true, // if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
modules: true, // if you use cssModules, this can help.
reloadAll: true, // when desperation kicks in - this is a brute force HMR flag

}
},
"css-loader"
]
}
Expand All @@ -90,10 +98,7 @@ module.exports = {
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css",
hot: true, // if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
orderWarning: true, // Disable to remove warnings about conflicting order between imports
reloadAll: true, // when desperation kicks in - this is a brute force HMR flag
cssModules: true // if you use cssModules, this can help.
}
),
]
Expand All @@ -116,7 +121,7 @@ This is a breaking change. The entire loader has been fundamentally rewritten sp

There have been some challenges along the way since the release of webpack 4. Ultimately the only remaining hurdle is code split, async style loading.

If you do need Webpack 3, make sure to stick with the latest `v2.x.x` release. `v3.x.x` is only intended for users with Webpack 4
If you do need Webpack 3, make sure to stick with the latest `v2.x.x` release. `> v3.x.x` is only intended for users with Webpack 4



Expand Down Expand Up @@ -151,15 +156,22 @@ With **webpack.optimize.CommonsChunkPlugin** plugin no longer part of Webpack 4,
*webpack.config.js:*
```js
const ExtractCssChunks = require("extract-css-chunks-webpack-plugin")
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); // or Terser plugin

module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
ExtractCssChunks.loader,
{
loader:ExtractCssChunks.loader,
options: {
hot: true,
modules: true,
reloadAll: true
},
},
{
loader: 'css-loader',
options: {
Expand Down Expand Up @@ -202,7 +214,9 @@ module.exports = {
}
},
plugins: [
new ExtractCssChunks({hot:true, cssModules: true}), //if you want HMR - we try to automatically inject hot reloading but if it's not working, add it to the config
new ExtractCssChunks({
filename: '[name].css',
}),
]
};
```
Expand Down
61 changes: 0 additions & 61 deletions RELEASE.md

This file was deleted.

10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
codecov:
branch: master
coverage:
precision: 2
round: down
range: 70...100
status:
project: 'no'
patch: 'yes'
comment: 'off'
32 changes: 0 additions & 32 deletions commitlint.config.js

This file was deleted.

27 changes: 0 additions & 27 deletions index.d.ts

This file was deleted.

0 comments on commit fd6d288

Please sign in to comment.