Skip to content

Commit

Permalink
Merge pull request #60 from homer0/next
Browse files Browse the repository at this point in the history
v7.0.0
  • Loading branch information
homer0 committed Feb 12, 2019
2 parents be34e41 + c3a2b56 commit 3d47bd6
Show file tree
Hide file tree
Showing 19 changed files with 4,947 additions and 3,814 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
8
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "6"
- "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
74 changes: 37 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,66 @@
"name": "projext-plugin-webpack",
"description": "Allows projext to use webpack as a build engine.",
"homepage": "https://homer0.github.io/projext-plugin-webpack/",
"version": "6.0.1",
"version": "7.0.0",
"repository": "homer0/projext-plugin-webpack",
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"dependencies": {
"projext": "^5.0.0",
"wootils": "^1.3.2",
"projext": "^6.0.0",
"wootils": "^2.0.0",
"jimple": "1.5.0",
"fs-extra": "7.0.0",
"fs-extra": "7.0.1",
"extend": "3.0.2",

"webpack": "4.16.5",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.5",
"mini-css-extract-plugin": "0.4.1",
"webpack": "4.29.1",
"webpack-cli": "3.2.1",
"webpack-dev-server": "3.1.14",
"mini-css-extract-plugin": "0.5.0",
"html-webpack-plugin": "3.2.0",
"script-ext-html-webpack-plugin": "2.0.1",
"compression-webpack-plugin": "1.1.11",
"uglifyjs-webpack-plugin": "1.3.0",
"optimize-css-assets-webpack-plugin": "5.0.0",
"copy-webpack-plugin": "4.5.2",
"script-ext-html-webpack-plugin": "2.1.3",
"compression-webpack-plugin": "2.0.0",
"uglifyjs-webpack-plugin": "2.1.1",
"optimize-css-assets-webpack-plugin": "5.0.1",
"copy-webpack-plugin": "4.6.0",

"babel-core": "6.26.3",
"node-sass": "4.9.3",
"@babel/core": "7.2.2",
"node-sass": "4.11.0",

"babel-loader": "7.1.5",
"css-loader": "1.0.0",
"babel-loader": "8.0.5",
"css-loader": "2.1.0",
"sass-loader": "7.1.0",
"style-loader": "0.22.1",
"raw-loader": "0.5.1",
"file-loader": "1.1.11",
"url-loader": "1.1.0",
"image-webpack-loader": "4.3.1",
"resolve-url-loader": "2.3.0",
"style-loader": "0.23.1",
"raw-loader": "1.0.0",
"file-loader": "3.0.1",
"url-loader": "1.1.2",
"image-webpack-loader": "4.6.0",
"resolve-url-loader": "3.0.0",
"source-map-loader": "0.2.4",

"webpack-dev-middleware": "3.1.3",
"webpack-hot-middleware": "2.22.3",
"webpack-dev-middleware": "3.5.1",
"webpack-hot-middleware": "2.24.3",

"opener": "1.5.0"
"opener": "1.5.1"
},
"devDependencies": {
"eslint": "5.3.0",
"eslint": "5.13.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "7.0.1",
"babel-preset-env": "1.7.0",
"jest-ex": "5.0.0",
"jest-cli": "23.5.0",
"jasmine-expect": "3.8.3",
"jimpex": "^2.1.1",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-node": "8.0.1",
"@babel/preset-env": "7.3.1",
"jest-ex": "^6.0.0",
"jest-cli": "24.0.0",
"jasmine-expect": "4.0.1",
"jimpex": "^3.0.0",
"esdoc": "1.1.0",
"esdoc-standard-plugin": "1.0.0",
"esdoc-node": "1.0.3",
"leasot": "6.3.0",
"esdoc-node": "1.0.4",
"leasot": "7.2.0",
"coveralls": "3.0.2"
},
"engine-strict": true,
"engines": {
"node": ">=6.0.0",
"node": ">=8.0.0",
"npm": ">=3.0.0"
},
"main": "src/index.js",
Expand Down
21 changes: 19 additions & 2 deletions src/services/building/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,27 @@ class WebpackConfiguration {
const entryFile = path.join(target.paths.source, target.entry[buildType]);
const entries = [entryFile];
if (target.babel.polyfill) {
entries.unshift('babel-polyfill');
entries.unshift('@babel/polyfill');
}

const copy = [];
if (target.is.browser || target.bundle) {
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
2 changes: 1 addition & 1 deletion src/services/configurations/baseConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class WebpackBaseConfiguration extends ConfigurationFile {
const { rules } = this.webpackRulesConfiguration.getConfig(params);
const config = {
resolve: {
extensions: ['.js', '.jsx'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
modules: ['./', 'node_modules'],
},
module: {
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 Expand Up @@ -214,7 +215,7 @@ class WebpackBrowserDevelopmentConfiguration extends ConfigurationFile {
// Get the list of entries for the target.
const entries = config.entry[entryName];
// Check if the `babel-polyfill` is present, since it always needs to be first.
const polyfillIndex = entries.indexOf('babel-polyfill');
const polyfillIndex = entries.indexOf('@babel/polyfill');
// If the `babel-polyfill` is present...
if (polyfillIndex > -1) {
// ...push all the _"hot entries"_ after it.
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
6 changes: 6 additions & 0 deletions src/services/configurations/nodeDevelopmentConfiguration.js
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 All @@ -109,6 +110,11 @@ class WebpackNodeDevelopmentConfiguration extends ConfigurationFile {
},
mode: 'development',
};
// If the target has source maps enabled...
if (target.sourceMap.development) {
// ...configure the devtool
config.devtool = 'source-map';
}
// Reduce the configuration.
return this.events.reduce(
[
Expand Down
6 changes: 6 additions & 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 All @@ -81,6 +82,11 @@ class WebpackNodeProductionConfiguration extends ConfigurationFile {
mode: 'production',
watch: target.watch.production,
};
// If the target has source maps enabled...
if (target.sourceMap.production) {
// ...configure the devtool
config.devtool = 'source-map';
}
// Reduce the configuration.
return this.events.reduce(
[
Expand Down
8 changes: 4 additions & 4 deletions src/services/configurations/rulesConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class WebpackRulesConfiguration extends ConfigurationFile {
// Set the base configuration for the CSS loader.
const cssLoaderConfig = {
// `2` because there are two other loaders after it: `resolve-url-loader` and `sass-loader`.
importRules: 2,
importLoaders: 2,
};
// If the target uses CSS modules...
if (target.css.modules) {
Expand All @@ -136,7 +136,7 @@ class WebpackRulesConfiguration extends ConfigurationFile {
const use = [
{
loader: 'css-loader',
query: cssLoaderConfig,
options: cssLoaderConfig,
},
'resolve-url-loader',
{
Expand Down Expand Up @@ -355,7 +355,7 @@ class WebpackRulesConfiguration extends ConfigurationFile {
},
{
loader: 'image-webpack-loader',
query: {
options: {
mozjpeg: {
progressive: true,
},
Expand Down Expand Up @@ -420,7 +420,7 @@ class WebpackRulesConfiguration extends ConfigurationFile {
},
{
loader: 'image-webpack-loader',
query: {
options: {
optipng: {
optimizationLevel: 7,
},
Expand Down
27 changes: 20 additions & 7 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 @@ -613,15 +620,17 @@ describe('services/building:configuration', () => {
buildType,
entry: {
[target.name]: [
'babel-polyfill',
'@babel/polyfill',
path.join(target.paths.source, target.entry[buildType]),
],
},
definitions: {
'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
Loading

0 comments on commit 3d47bd6

Please sign in to comment.