Skip to content

Commit

Permalink
Set the mode flag in the webpack config.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradyvercher committed Aug 3, 2018
1 parent 008d78b commit 971f94b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const webpack = require( 'webpack' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
const mode = process.env.NODE_ENV || 'development';

const editorCSSPlugin = new ExtractTextPlugin( {
filename: 'build/css/editor.css'
Expand Down Expand Up @@ -26,6 +28,7 @@ const extractConfig = {
};

const config = {
mode: mode,
entry: {
'js/editor.js': './blocks/editor.js',
'css/themes/atom-one-dark/prism.css': './blocks/code/scss/themes/atom-one-dark/prism.scss',
Expand Down Expand Up @@ -73,7 +76,9 @@ const config = {
]
};

if ( 'production' !== process.env.NODE_ENV ) {
if ( 'production' === mode ) {
config.plugins.push( new webpack.LoaderOptionsPlugin( { minimize: true } ) );
} else {
config.devtool = process.env.SOURCEMAP || 'source-map';
}

Expand Down

0 comments on commit 971f94b

Please sign in to comment.