Skip to content

Commit

Permalink
Add support for the new node target output settings
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Feb 28, 2018
1 parent c25d81f commit e1df4c0
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 177 deletions.
13 changes: 1 addition & 12 deletions src/services/building/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ class WebpackConfiguration {

return definitions;
}
/**
* Generate the output paths for a target files.
* @param {Target} target The target information.
* @param {string} buildType The intended build type: `production` or `development`.
* @return {WebpackConfigurationTargetOutput}
*/
getOutput(target, buildType) {
return target.is.node ?
{ js: target.output[buildType] } :
Object.assign({}, target.output[buildType]);
}
/**
* In case the target is a library, this method will be called to generate the library options
* for Webpack.
Expand Down Expand Up @@ -125,7 +114,7 @@ class WebpackConfiguration {
[target.name]: entries,
},
definitions: this.getDefinitions(target, buildType),
output: this.getOutput(target, buildType),
output: target.output[buildType],
buildType,
};

Expand Down
5 changes: 4 additions & 1 deletion src/services/configurations/nodeDevelopmentConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const webpackNodeUtils = require('webpack-node-utils');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const {
NoEmitOnErrorsPlugin,
} = require('webpack');
Expand Down Expand Up @@ -54,8 +55,10 @@ class WebpackNodeDevelopmentConfiguration extends ConfigurationFile {
const plugins = [
// To avoid pushing assets with errors.
new NoEmitOnErrorsPlugin(),
// To optimize the SCSS and remove repeated declarations.
new OptimizeCssAssetsPlugin(),
];
// If the target needsto run on development...
// If the target needs to run on development...
if (target.runOnDevelopment) {
// ...watch the source files.
watch = true;
Expand Down
3 changes: 3 additions & 0 deletions src/services/configurations/nodeProductionConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const webpackNodeUtils = require('webpack-node-utils');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const {
NoEmitOnErrorsPlugin,
} = require('webpack');
Expand Down Expand Up @@ -59,6 +60,8 @@ class WebpackNodeProductionConfiguration extends ConfigurationFile {
plugins: [
// To avoid pushing assets with errors.
new NoEmitOnErrorsPlugin(),
// To optimize the SCSS and remove repeated declarations.
new OptimizeCssAssetsPlugin(),
],
target: 'node',
node: {
Expand Down

0 comments on commit e1df4c0

Please sign in to comment.