-
-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack-cli): fixed support for SCSS entry points (#1271)
* fix(webpack-cli): fixed support for SCSS entry points * fix(webpack-cli): use children only when configuration is an array * fix(webpack-cli): added tests correctly * fix(webpack-cli): increased time out for installing deps * tests(webpack-cli): enforced time out * tests(webpack-cli): fix correct cwd when installing deps * tests(webpack-cli): fix correct cwd when installing deps * tests(webpack-cli): install all packages before launching the tests
- Loading branch information
Showing
14 changed files
with
190 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const execa = require('execa'); | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const chalk = require('chalk'); | ||
|
||
const BASE_DIR = 'test/'; | ||
const PACKAGE = 'package.json'; | ||
|
||
function collectTestingFoldersWithPackage() { | ||
const testFolder = path.resolve(path.join(process.cwd(), BASE_DIR)); | ||
|
||
return extractFolder(testFolder); | ||
} | ||
|
||
function extractFolder(folderToRead, folders = []) { | ||
const files = fs.readdirSync(folderToRead); | ||
|
||
files.forEach(file => { | ||
const filePath = path.resolve(path.join(folderToRead, file)); | ||
const stats = fs.statSync(filePath); | ||
if (stats.isFile() && file === PACKAGE) { | ||
folders.push(folderToRead); | ||
} | ||
if (stats.isDirectory() && file !== 'node_modules') { | ||
extractFolder(filePath, folders); | ||
} | ||
}); | ||
|
||
return folders; | ||
} | ||
|
||
{ | ||
Promise.all( | ||
collectTestingFoldersWithPackage().map(async folder => { | ||
return execa('yarn', { | ||
cwd: folder, | ||
stdio: 'inherit', | ||
}); | ||
}), | ||
) | ||
.then(() => { | ||
console.log(chalk.inverse.green(' Successfully prepared the test suite ')); | ||
}) | ||
.catch(e => { | ||
console.error(chalk.inverse.red(' Unable to prepare the test suite ')); | ||
console.error(e.stack); | ||
process.exitCode = 1; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
yarn.lock | ||
package-lock.json | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('home'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
body { | ||
font-size: 100%; | ||
body { | ||
background-color: red; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"dependencies": { | ||
"css-loader": "^3.4.2", | ||
"style-loader": "^1.1.3", | ||
"sass-loader": "^8.0.2", | ||
"mini-css-extract-plugin": "^0.9.0", | ||
"node-sass": "^4.13.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable node/no-missing-require */ | ||
/* eslint-disable node/no-unpublished-require */ | ||
const { run, runInstall } = require('../../utils/test-utils'); | ||
|
||
jest.setTimeout(1000 * 60 * 5); | ||
|
||
describe('entry point', () => { | ||
it('should support SCSS files', async () => { | ||
await runInstall(__dirname); | ||
const { stdout } = run(__dirname); | ||
expect(stdout).toBeTruthy(); | ||
expect(stdout).toContain('home.scss'); | ||
expect(stdout).toContain('home.js'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable node/no-missing-require */ | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
entry: { | ||
home: ['./home.js', './home.scss'], | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
// fallback to style-loader in development | ||
MiniCssExtractPlugin.loader, | ||
'css-loader', | ||
'sass-loader', | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: '[name].css', | ||
}), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
yarn.lock | ||
package-lock.json | ||
node_modules/ | ||
*.js | ||
*.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
// eslint-disable-next-line node/no-unpublished-require | ||
/* eslint-disable node/no-missing-require */ | ||
/* eslint-disable node/no-unpublished-require */ | ||
const { run, runInstall } = require('../utils/test-utils'); | ||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
jest.setTimeout(1000 * 60 * 5); | ||
|
||
describe('webpack cli', () => { | ||
it('should support typescript file', async () => { | ||
await runInstall(__dirname); | ||
const { stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, 'bin/foo.bundle.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
}); | ||
}); | ||
it( | ||
'should support typescript file', | ||
async () => { | ||
await runInstall(__dirname); | ||
const { stderr, stdout } = run(__dirname, ['-c', './webpack.config.ts']); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
stat(resolve(__dirname, 'bin/foo.bundle.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
}); | ||
}, | ||
1000 * 60 * 5, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters