Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
refactor(ExtractTextPlugin): update to new plugin system and API's (#707
Browse files Browse the repository at this point in the history
)

BREAKING CHANGE: requires `webpack >= v4.0.0`
  • Loading branch information
horo42 authored and michael-ciniawsky committed Feb 14, 2018
1 parent 10a1785 commit 51c56c0
Show file tree
Hide file tree
Showing 13 changed files with 6,972 additions and 253 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ new ExtractTextPlugin(options: filename | object)
|:--:|:--:|:----------|
|**`id`**|`{String}`|Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)|
|**`filename`**|`{String\|Function}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`|
|**`allChunks`**|`{Boolean}`|Extract from all additional chunks too (by default it extracts only from the initial chunk(s))<br />When using `CommonsChunkPlugin` and there are extracted chunks (from `ExtractTextPlugin.extract`) in the commons chunk, `allChunks` **must** be set to `true`|
|**`allChunks`**|`{Boolean}`|Extract from all additional chunks too (by default it extracts only from the initial chunk(s))<br />When using `optimization.splitChunks` and there are extracted chunks (from `ExtractTextPlugin.extract`) in the commons chunk, `allChunks` **must** be set to `true`|
|**`disable`**|`{Boolean}`|Disables the plugin|
|**`ignoreOrder`**|`{Boolean}`|Disables order check (useful for CSS Modules!), `false` by default|

Expand Down
80 changes: 44 additions & 36 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
var webpack = require("webpack");
var ExtractTextPlugin = require("../");
const ExtractTextPlugin = require('../');

module.exports = {
entry: {
a: "./entry.js",
b: "./entry2.js"
},
output: {
filename: "[name].js?[hash]-[chunkhash]",
chunkFilename: "[name].js?[hash]-[chunkhash]",
path: __dirname + "/assets",
publicPath: "/assets/"
},
module: {
loaders: [
{ test: /\.css$/, use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: {
loader: "css-loader",
options: {
sourceMap: true
}
},
publicPath: "../"
}) },
{ test: /\.png$/, loader: "file-loader" }
]
},
devtool: "source-map",
plugins: [
new ExtractTextPlugin({
filename: "css/[name].css?[hash]-[chunkhash]-[contenthash]-[name]",
disable: false,
allChunks: true
}),
new webpack.optimize.CommonsChunkPlugin({ name: "c", filename: "c.js" })
]
entry: {
a: './entry.js',
b: './entry2.js',
},
output: {
filename: '[name].js?[hash]-[chunkhash]',
chunkFilename: '[name].js?[hash]-[chunkhash]',
path: `${__dirname}/assets`,
publicPath: '/assets/',
},
module: {
loaders: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: {
loader: 'css-loader',
options: {
sourceMap: true,
},
},
publicPath: '../',
}),
},
{ test: /\.png$/, loader: 'file-loader' },
],
},
devtool: 'source-map',
optimization: {
splitChunks: {
chunks: 'all',
name: 'c',
},
},
plugins: [
new ExtractTextPlugin({
filename: 'css/[name].css?[hash]-[chunkhash]-[contenthash]-[name]',
disable: false,
allChunks: true,
}),
],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"raw-loader": "^0.5.1",
"standard-version": "^4.2.0",
"style-loader": "^0.19.1",
"webpack": "^4.0.0-alpha.2",
"webpack": "^4.0.0-beta.1",
"webpack-defaults": "^2.0.0-rc.3"
},
"engines": {
Expand Down
Loading

0 comments on commit 51c56c0

Please sign in to comment.