Skip to content

Commit

Permalink
Merge 22f5908 into d377712
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Feb 7, 2019
2 parents d377712 + 22f5908 commit 46eebbc
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 245 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "8.11"
- "10.15"
after_success:
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Allows [projext](https://yarnpkg.com/en/package/projext) to use [webpack](https:
|--------------|-------------------------------------------------------------------------------|
| Package | projext-plugin-webpack |
| Description | Allows projext to use webpack as a build engine. |
| Node Version | >= v6.10.0 |
| Node Version | >= v8.0.0 |

## Usage

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "MIT",
"dependencies": {
"projext": "homer0/projext#next",
"wootils": "^1.4.0",
"wootils": "^2.0.0",
"jimple": "1.5.0",
"fs-extra": "7.0.1",
"extend": "3.0.2",
Expand Down Expand Up @@ -52,7 +52,7 @@
"jest-ex": "^6.0.0",
"jest-cli": "24.0.0",
"jasmine-expect": "4.0.1",
"jimpex": "^2.1.1",
"jimpex": "^3.0.0",
"esdoc": "1.1.0",
"esdoc-standard-plugin": "1.0.0",
"esdoc-node": "1.0.4",
Expand Down
19 changes: 18 additions & 1 deletion src/services/building/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ class WebpackConfiguration {
copy.push(...this.targets.getFilesToCopy(target, buildType));
}

const output = Object.assign({}, target.output[buildType]);
if (typeof output.jsChunks !== 'string') {
output.jsChunks = this._generateChunkName(output.js);
}

const params = {
target,
targetRules: this.targetsFileRules.getRulesForTarget(target),
entry: {
[target.name]: entries,
},
definitions: this._getDefinitions(target, buildType),
output: target.output[buildType],
output,
copy,
buildType,
};
Expand Down Expand Up @@ -162,6 +167,18 @@ class WebpackConfiguration {

return newOptions;
}
/**
* This is a small helper function that parses the default path of the JS file webpack will
* emmit and adds a `[name]` placeholder for webpack to replace with the chunk name.
* @param {string} jsPath The original path for the JS file.
* @return {string}
* @access protected
* @ignore
*/
_generateChunkName(jsPath) {
const parsed = path.parse(jsPath);
return path.join(parsed.dir, `${parsed.name}.[name]${parsed.ext}`);
}
}
/**
* The service provider that once registered on the app container will set an instance of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class WebpackBrowserDevelopmentConfiguration extends ConfigurationFile {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class WebpackBrowserProductionConfiguration extends ConfigurationFile {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'production',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class WebpackNodeDevelopmentConfiguration extends ConfigurationFile {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
watch,
Expand Down
1 change: 1 addition & 0 deletions src/services/configurations/nodeProductionConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class WebpackNodeProductionConfiguration extends ConfigurationFile {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
plugins: [
Expand Down
25 changes: 19 additions & 6 deletions tests/services/building/configuration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ describe('services/building:configuration', () => {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
targetRules,
copy: [],
});
Expand Down Expand Up @@ -298,7 +300,9 @@ describe('services/building:configuration', () => {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
targetRules,
copy: filesToCopy,
});
Expand Down Expand Up @@ -351,6 +355,7 @@ describe('services/building:configuration', () => {
output: {
[buildType]: {
js: 'js/target/file.2509.js',
jsChunks: 'js/target/file.2509.[name].js',
css: 'css/target/file.2509.css',
fonts: 'fonts/target/[name].2509.[ext]',
images: 'images/target/[name].2509.[ext]',
Expand Down Expand Up @@ -508,7 +513,9 @@ describe('services/building:configuration', () => {
entry: {
[target.name]: [path.join(target.paths.source, target.entry[buildType])],
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
definitions: {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
Expand Down Expand Up @@ -621,7 +628,9 @@ describe('services/building:configuration', () => {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
targetRules,
copy: [],
});
Expand Down Expand Up @@ -727,7 +736,9 @@ describe('services/building:configuration', () => {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
targetRules,
copy: [],
});
Expand Down Expand Up @@ -835,7 +846,9 @@ describe('services/building:configuration', () => {
'process.env.NODE_ENV': `'${buildType}'`,
[versionVariable]: `"${version}"`,
},
output: target.output[buildType],
output: Object.assign({}, target.output[buildType], {
jsChunks: target.output[buildType].js.replace(/\.js$/, '.[name].js'),
}),
targetRules,
copy: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand All @@ -125,6 +126,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -218,6 +220,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand All @@ -233,6 +236,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -324,6 +328,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand All @@ -344,6 +349,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -438,6 +444,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand All @@ -453,6 +460,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -560,6 +568,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -590,6 +599,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -703,6 +713,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -734,6 +745,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -850,6 +862,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -877,6 +890,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -994,6 +1008,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -1026,6 +1041,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -1146,6 +1162,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -1177,6 +1194,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -1295,6 +1313,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -1327,6 +1346,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down Expand Up @@ -1445,6 +1465,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
};
const output = {
js: 'statics/js/build.js',
jsChunks: 'statics/js/build.[name].js',
css: 'statics/css/build.css',
};
const copy = ['file-to-copy'];
Expand Down Expand Up @@ -1477,6 +1498,7 @@ describe('services/configurations:browserDevelopmentConfiguration', () => {
output: {
path: `./${target.folders.build}`,
filename: output.js,
chunkFilename: output.jsChunks,
publicPath: '/',
},
mode: 'development',
Expand Down

0 comments on commit 46eebbc

Please sign in to comment.