Skip to content

Commit 5f2961d

Browse files
committed
fix(package): replace extract-text-webpack-plugin with mini-css-extract-plugin
Note: This restores the demo watch feature; however, AOT is temporarily disabled because mini-css-extract-plugin has an issue with AngularCompilerPlugin See: webpack-contrib/mini-css-extract-plugin#186
1 parent 032e307 commit 5f2961d

File tree

4 files changed

+81
-81
lines changed

4 files changed

+81
-81
lines changed

config/webpack.common.js

+19-22
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ const path = require('path'),
99
/**
1010
* Webpack Plugins
1111
*/
12-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
12+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1313
const HtmlWebpackPlugin = require('html-webpack-plugin');
1414
const OptimizeJsPlugin = require('optimize-js-plugin');
1515

16-
// ExtractTextPlugin
17-
const extractCSS = new ExtractTextPlugin({
18-
filename: '[name].[id].css',
19-
allChunks: true
16+
// MiniCssExtractPlugin
17+
const extractCSS = new MiniCssExtractPlugin({
18+
filename: '[name].css',
19+
chunkFilename: "[id].css"
2020
});
2121

2222
module.exports = {
@@ -56,18 +56,14 @@ module.exports = {
5656
*/
5757
{
5858
test: /\.css$/,
59-
use: extractCSS.extract({
60-
fallback: "style-loader",
61-
use: [
62-
{
63-
loader: 'css-loader',
64-
options: {
65-
sourceMap: true,
66-
context: '/'
67-
},
68-
},
69-
]
70-
})
59+
use: [
60+
MiniCssExtractPlugin.loader, {
61+
loader: "css-loader",
62+
options: {
63+
minimize: true,
64+
sourceMap: true
65+
}
66+
}]
7167
},
7268

7369
/**
@@ -113,20 +109,22 @@ module.exports = {
113109
}
114110
]
115111
},
116-
112+
/*
117113
optimization: {
118114
splitChunks: {
119115
cacheGroups: {
120116
commons: {
121117
test: /[\\/]node_modules[\\/]/,
122-
name: "vendors",
118+
name: "styles",
123119
chunks: "all"
124120
}
125121
}
126122
}
127123
},
128-
124+
*/
129125
plugins: [
126+
extractCSS,
127+
130128
/**
131129
* Plugin: ContextReplacementPlugin
132130
* Description: Provides context to Angular's use of System.import
@@ -188,7 +186,6 @@ module.exports = {
188186
root: helpers.root(),
189187
verbose: false,
190188
dry: false
191-
}),
192-
extractCSS
189+
})
193190
]
194191
};

config/webpack.demo.js

+19-23
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ const path = require('path');
77
*/
88
const AotPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
99
const CopyWebpackPlugin = require('copy-webpack-plugin');
10-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
1110
const HtmlWebpackPlugin = require('html-webpack-plugin');
11+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1212
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
1313
const TypedocWebpackPlugin = require('typedoc-webpack-plugin');
1414

15-
// ExtractTextPlugin
16-
const extractCSS = new ExtractTextPlugin({
17-
filename: '[name].[id].css',
18-
allChunks: true
15+
// MiniCssExtractPlugin
16+
const extractCSS = new MiniCssExtractPlugin({
17+
filename: '[name].css',
18+
chunkFilename: "[id].css"
1919
});
2020

21-
const aotMode = true;
21+
// NOTE: AOT is temporarily disabled because mini-css-extract-plugin has an issue with AngularCompilerPlugin
22+
// See: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/186
23+
const aotMode = false;
2224

2325
module.exports = {
2426
devServer: {
25-
stats: 'minimal',
26-
inline: true
27+
inline: true,
28+
stats: 'minimal'
2729
},
2830

2931
devtool: 'cheap-module-eval-source-map',
@@ -52,7 +54,6 @@ module.exports = {
5254
use: aotMode ? [
5355
'@ngtools/webpack'
5456
] : [
55-
// 'awesome-typescript-loader',
5657
'ts-loader',
5758
'angular2-template-loader'
5859
],
@@ -88,19 +89,14 @@ module.exports = {
8889
*/
8990
{
9091
test: /\.css$/,
91-
use: extractCSS.extract({
92-
fallback: "style-loader",
93-
use: [
94-
{
95-
loader: 'css-loader',
96-
options: {
97-
sourceMap: true,
98-
context: '/'
99-
},
100-
},
101-
]
102-
}),
103-
exclude: [/node_modules\/@swimlane\/ngx-datatable/]
92+
use: [
93+
MiniCssExtractPlugin.loader, {
94+
loader: "css-loader",
95+
options: {
96+
minimize: true,
97+
sourceMap: true
98+
}
99+
}]
104100
},
105101
{
106102
test: /\.less$/,
@@ -175,7 +171,7 @@ module.exports = {
175171
cacheGroups: {
176172
commons: {
177173
test: /[\\/]node_modules[\\/]/,
178-
name: "vendors",
174+
name: "styles",
179175
chunks: "all"
180176
}
181177
}

gulpfile.js

+6
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ gulp.task('build',
129129

130130
// Build the components
131131
gulp.task('transpile', ['inline-template'], function () {
132+
// Stick with v0.2.1 due to "function calls are not supported in decorators" issue
133+
// See: https://github.com/angular/angular/issues/23609
134+
// See: https://github.com/dherges/ng-packagr/issues/727
135+
136+
// Change for v0.3.0 https://github.com/filipesilva/angular-quickstart-lib/issues/61
137+
// return ngc(['--project', 'tsconfig-prod.json']);
132138
return ngc('tsconfig-prod.json');
133139
});
134140

package.json

+37-36
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"reinstall": "npm run clean && npm install",
2222
"remove-dist": "rimraf build dist dist-watch dist-demo",
2323
"rimraf": "rimraf",
24-
"start:demo": "npm run webpack-dev-server -- --config config/webpack.demo.js --progress --host 0.0.0.0 --port 8001 --profile --watch --content-base dist-demo",
24+
"start:demo": "npm run webpack-dev-server -- --config config/webpack.demo.js --host 0.0.0.0 --port 8001 --progress --profile --hot --content-base dist-demo",
2525
"test": "karma start",
2626
"test:trace-deprecation": "node --trace-deprecation ./node_modules/.bin/karma start",
2727
"test:debug": "karma --browsers Chrome --no-single-run start",
@@ -81,58 +81,57 @@
8181
},
8282
"optionalDependencies": {},
8383
"devDependencies": {
84-
"@angular-devkit/core": "0.6.3",
85-
"@angular/animations": "6.0.2",
86-
"@angular/common": "6.0.2",
87-
"@angular/compiler": "6.0.2",
88-
"@angular/compiler-cli": "6.0.2",
89-
"@angular/core": "6.0.2",
90-
"@angular/forms": "6.0.2",
91-
"@angular/http": "6.0.2",
92-
"@angular/platform-browser": "6.0.2",
93-
"@angular/platform-browser-dynamic": "6.0.2",
94-
"@angular/platform-server": "6.0.2",
95-
"@angular/router": "6.0.2",
96-
"@ngtools/webpack": "6.0.3",
84+
"@angular-devkit/core": "0.6.6",
85+
"@angular/animations": "6.0.6",
86+
"@angular/common": "6.0.6",
87+
"@angular/compiler": "6.0.6",
88+
"@angular/compiler-cli": "6.0.6",
89+
"@angular/core": "6.0.6",
90+
"@angular/forms": "6.0.6",
91+
"@angular/http": "6.0.6",
92+
"@angular/platform-browser": "6.0.6",
93+
"@angular/platform-browser-dynamic": "6.0.6",
94+
"@angular/platform-server": "6.0.6",
95+
"@angular/router": "6.0.6",
96+
"@ngtools/webpack": "6.0.8",
9797
"@types/c3": "0.6.0",
98-
"@types/jasmine": "2.8.7",
99-
"@types/lodash": "4.14.109",
98+
"@types/jasmine": "2.8.8",
99+
"@types/lodash": "4.14.110",
100100
"angular2-template-loader": "0.6.2",
101101
"bootstrap": "3.3.7",
102102
"bootstrap-sass": "3.3.7",
103103
"child_process": "1.0.2",
104104
"clean-webpack-plugin": "0.1.19",
105-
"codelyzer": "4.3.0",
106-
"commitizen": "2.9.6",
107-
"copy-webpack-plugin": "4.5.1",
108-
"core-js": "2.5.6",
105+
"codelyzer": "4.4.2",
106+
"commitizen": "2.10.1",
107+
"copy-webpack-plugin": "4.5.2",
108+
"core-js": "2.5.7",
109109
"css-loader": "0.28.11",
110110
"css-to-string-loader": "0.1.3",
111111
"cz-conventional-changelog": "2.1.0",
112112
"del": "3.0.0",
113-
"extract-text-webpack-plugin": "next",
114113
"file-loader": "1.1.11",
115114
"font-awesome-sass": "4.7.0",
116115
"gulp": "3.9.1",
117116
"gulp-changed": "3.2.0",
118117
"gulp-cssmin": "0.2.0",
119118
"gulp-less": "3.5.0",
120119
"gulp-ngc": "0.2.1",
121-
"gulp-rename": "1.2.3",
120+
"gulp-rename": "1.3.0",
122121
"gulp-replace": "1.0.0",
123122
"gulp-sass": "3.2.1",
124123
"gulp-sourcemaps": "2.6.4",
125124
"gulp-string-replace": "1.0.0",
126125
"gulp-stylelint": "7.0.0",
127126
"highlight.js": "9.12.0",
128127
"html-loader": "0.5.5",
129-
"html-minifier": "3.5.16",
128+
"html-minifier": "3.5.17",
130129
"html-webpack-plugin": "3.2.0",
131130
"husky": "0.14.3",
132131
"jasmine-core": "3.1.0",
133132
"json-loader": "0.5.7",
134133
"json-stringify": "1.0.0",
135-
"karma": "2.0.2",
134+
"karma": "2.0.4",
136135
"karma-chrome-launcher": "2.2.0",
137136
"karma-cli": "1.0.1",
138137
"karma-coverage": "1.1.2",
@@ -146,45 +145,47 @@
146145
"less": "2.7.3",
147146
"less-loader": "4.1.0",
148147
"markdown-it": "8.4.1",
148+
"mini-css-extract-plugin": "0.4.0",
149149
"mocha": "5.2.0",
150150
"npm-run-all": "4.1.3",
151151
"nsp": "3.2.1",
152152
"optimize-js-plugin": "0.0.4",
153153
"patternfly-eng-publish": "0.0.4",
154-
"patternfly-eng-release": "^3.26.67",
154+
"patternfly-eng-release": "^3.26.69",
155155
"phantomjs-prebuilt": "2.1.16",
156156
"protractor": "5.3.2",
157157
"raw-loader": "0.5.1",
158158
"reflect-metadata": "0.1.12",
159159
"rimraf": "2.6.2",
160-
"rxjs": "6.1.0",
161-
"rxjs-compat": "6.1.0",
162-
"sass": "1.6.2",
163-
"sass-loader": "7.0.3",
164-
"semantic-release": "15.5.0",
160+
"rollup": "0.61.2",
161+
"rollup-plugin-commonjs": "9.1.3",
162+
"rollup-plugin-node-resolve": "3.3.0",
163+
"rollup-plugin-uglify": "4.0.0",
164+
"rxjs": "6.2.1",
165+
"rxjs-compat": "6.2.1",
166+
"semantic-release": "15.6.0",
165167
"source-map-loader": "0.2.3",
166168
"style-loader": "0.21.0",
167-
"stylelint": "9.2.1",
169+
"stylelint": "9.3.0",
168170
"stylelint-config-recommended-scss": "3.2.0",
169171
"stylelint-config-standard": "18.2.0",
170172
"stylelint-order": "0.8.1",
171173
"stylelint-scss": "3.0.0",
172174
"stylus": "0.54.5",
173175
"to-string-loader": "1.1.5",
174176
"ts-helpers": "1.1.2",
175-
"ts-node": "6.0.3",
177+
"ts-node": "6.2.0",
176178
"tslint": "5.10.0",
177-
"ts-loader": "4.3.1",
179+
"ts-loader": "4.4.1",
178180
"typedoc": "0.11.1",
179181
"typedoc-webpack-plugin": "1.1.4",
180182
"typescript": "2.7.2",
181183
"url-loader": "1.0.1",
182-
"webpack": "4.8.3",
183-
"webpack-bundle-analyzer": "2.13.0",
184+
"webpack": "4.12.1",
185+
"webpack-bundle-analyzer": "2.13.1",
184186
"webpack-cli": "2.1.3",
185187
"webpack-dashboard": "1.1.1",
186188
"webpack-dev-server": "3.1.4",
187-
"webpack-md5-hash": "0.0.6",
188189
"webpack-merge": "4.1.2",
189190
"zone.js": "0.8.26"
190191
},

0 commit comments

Comments
 (0)