Skip to content

Moving minification options #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ConfigGenerator {
buildRulesConfig() {
const cssLoaders = [
{
loader: 'css-loader' + this.getSourceMapOption(),
loader: 'css-loader' + this.getSourceMapOption() + (this.webpackConfig.isProduction() ? '?minimize=1' : ''),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this use options instead of the query string way ?

},
];
if (this.webpackConfig.usePostCssLoader) {
Expand Down Expand Up @@ -292,7 +292,6 @@ class ConfigGenerator {
* https://github.com/jtangelder/sass-loader/issues/285
*/
plugins.push(new webpack.LoaderOptionsPlugin({
minimize: this.webpackConfig.isProduction(),
debug: !this.webpackConfig.isProduction(),
options: {
context: this.webpackConfig.getContext(),
Expand Down
2 changes: 0 additions & 2 deletions test/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ describe('The config-generator function', () => {
const actualConfig = configGenerator(config);

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

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

const moduleHashedIdsPlugin = findPlugin(webpack.HashedModuleIdsPlugin, actualConfig.plugins);
Expand Down
6 changes: 6 additions & 0 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,19 @@ describe('Functional tests using webpack', function() {
const config = createWebpackConfig('www/build', 'production');
config.setPublicPath('/build');
config.addEntry('main', ['./js/no_require']);
config.addEntry('styles', './css/h1_style.css');

testSetup.runWebpack(config, (webpackAssert) => {
// the comment should not live in the file
webpackAssert.assertOutputFileDoesNotContain(
'main.js',
'// comments in no_require.js'
);
// extra spaces should not live in the CSS file
webpackAssert.assertOutputFileDoesNotContain(
'styles.css',
' font-size: 50px;'
);

done();
});
Expand Down