Skip to content

Commit 8cb76dc

Browse files
authored
Merge pull request #4 from weaverryan/fix-sass-production-resolving
Moving minification options
2 parents a60bbdf + 46164f5 commit 8cb76dc

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/config-generator.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ConfigGenerator {
100100
buildRulesConfig() {
101101
const cssLoaders = [
102102
{
103-
loader: 'css-loader' + this.getSourceMapOption(),
103+
loader: 'css-loader' + this.getSourceMapOption() + (this.webpackConfig.isProduction() ? '?minimize=1' : ''),
104104
},
105105
];
106106
if (this.webpackConfig.usePostCssLoader) {
@@ -292,7 +292,6 @@ class ConfigGenerator {
292292
* https://github.com/jtangelder/sass-loader/issues/285
293293
*/
294294
plugins.push(new webpack.LoaderOptionsPlugin({
295-
minimize: this.webpackConfig.isProduction(),
296295
debug: !this.webpackConfig.isProduction(),
297296
options: {
298297
context: this.webpackConfig.getContext(),

test/config-generator.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ describe('The config-generator function', () => {
221221
const actualConfig = configGenerator(config);
222222

223223
const loaderOptionsPlugin = findPlugin(webpack.LoaderOptionsPlugin, actualConfig.plugins);
224-
expect(loaderOptionsPlugin.options.minimize).to.equal(false);
225224
expect(loaderOptionsPlugin.options.debug).to.equal(true);
226225
expect(loaderOptionsPlugin.options.options.context).to.equal('/tmp/context');
227226
expect(loaderOptionsPlugin.options.options.output.path).to.equal('/tmp/output/public-path');
@@ -242,7 +241,6 @@ describe('The config-generator function', () => {
242241
const actualConfig = configGenerator(config);
243242

244243
const loaderOptionsPlugin = findPlugin(webpack.LoaderOptionsPlugin, actualConfig.plugins);
245-
expect(loaderOptionsPlugin.options.minimize).to.equal(true);
246244
expect(loaderOptionsPlugin.options.debug).to.equal(false);
247245

248246
const moduleHashedIdsPlugin = findPlugin(webpack.HashedModuleIdsPlugin, actualConfig.plugins);

test/functional.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,19 @@ describe('Functional tests using webpack', function() {
414414
const config = createWebpackConfig('www/build', 'production');
415415
config.setPublicPath('/build');
416416
config.addEntry('main', ['./js/no_require']);
417+
config.addEntry('styles', './css/h1_style.css');
417418

418419
testSetup.runWebpack(config, (webpackAssert) => {
419420
// the comment should not live in the file
420421
webpackAssert.assertOutputFileDoesNotContain(
421422
'main.js',
422423
'// comments in no_require.js'
423424
);
425+
// extra spaces should not live in the CSS file
426+
webpackAssert.assertOutputFileDoesNotContain(
427+
'styles.css',
428+
' font-size: 50px;'
429+
);
424430

425431
done();
426432
});

0 commit comments

Comments
 (0)