forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
251 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('babel/register'); |
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,47 @@ | ||
export default { | ||
configFile: 'webpack.config.js', | ||
tests: [ | ||
// npm run build | `webpack --bail` | ||
{ | ||
args: '', | ||
expected: { | ||
entry: { 'react-bootstrap': './src/index.js' }, | ||
output: | ||
{ path: './dist', | ||
filename: '[name].js', | ||
library: 'ReactBootstrap', | ||
libraryTarget: 'umd' }, | ||
externals: | ||
[ { react: | ||
{ root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react' } } ], | ||
module: { loaders: [ { test: /\.js/, loader: 'babel', exclude: /node_modules/ } ] }, | ||
plugins: [ { definitions: { 'process.env': { NODE_ENV: '"development"' } } } ] | ||
} | ||
}, | ||
|
||
// npm run build | `webpack --bail -p` | ||
{ | ||
args: 'p', | ||
expected: { | ||
entry: { 'react-bootstrap': './src/index.js' }, | ||
output: | ||
{ path: './dist', | ||
filename: '[name].min.js', | ||
library: 'ReactBootstrap', | ||
libraryTarget: 'umd' }, | ||
externals: | ||
[ { react: | ||
{ root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react' } } ], | ||
module: { loaders: [ { test: /\.js/, loader: 'babel', exclude: /node_modules/ } ] }, | ||
plugins: [ { definitions: { 'process.env': { NODE_ENV: '"production"' } } } ], | ||
devtool: 'source-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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import path from 'path'; | ||
const root = path.join(__dirname, '../../'); | ||
|
||
export default { | ||
configFile: 'webpack.docs.js', | ||
tests: [ | ||
|
||
// npm run docs | ||
{ | ||
args: 'd', | ||
expected: { | ||
entry: | ||
{ bundle: | ||
[ 'webpack/hot/dev-server', | ||
'webpack-dev-server/client?http://localhost:8080', | ||
'./docs/client.js' ] }, | ||
output: | ||
{ filename: '[name].js', | ||
path: './docs-built/assets', | ||
publicPath: 'http://localhost:8080/assets/' }, | ||
externals: undefined, | ||
module: | ||
{ noParse: /babel-core\/browser/, | ||
loaders: | ||
[ { test: /\.js/, | ||
loader: 'react-hot!babel', | ||
exclude: /node_modules|Samples\.js/ }, | ||
{ test: /Samples.js/, loader: 'react-hot!transform?brfs!babel' }, | ||
{ test: /\.css/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css?sourceMap` }, | ||
{ test: /\.less$/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css?sourceMap!less?sourceMap` }, | ||
{ test: /\.json$/, loader: 'json' }, | ||
{ test: /\.jpe?g$|\.gif$|\.png|\.ico$/, | ||
loader: 'file?name=[name].[ext]' }, | ||
{ test: /\.eot$|\.ttf$|\.svg$|\.woff2?$/, | ||
loader: 'file?name=[name].[ext]' } ] }, | ||
plugins: | ||
[ { definitions: { 'process.env': { NODE_ENV: '"development"' } } }, | ||
{ filename: '[name].css', options: {}, id: 1 }, | ||
{} ] | ||
} | ||
}, | ||
|
||
// npm run build | ||
// npm run docs-build | ||
// npm run docs-prod | ||
{ | ||
args: 'p', | ||
expected: { | ||
entry: { bundle: './docs/client.js' }, | ||
output: | ||
{ filename: '[name].js', | ||
path: './docs-built/assets', | ||
publicPath: '/assets/' }, | ||
externals: undefined, | ||
module: | ||
{ noParse: /babel-core\/browser/, | ||
loaders: | ||
[ { test: /\.js/, | ||
loader: 'babel', | ||
exclude: /node_modules|Samples\.js/ }, | ||
{ test: /Samples.js/, loader: 'transform?brfs!babel' }, | ||
{ test: /\.css/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css` }, | ||
{ test: /\.less$/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css!less` }, | ||
{ test: /\.json$/, loader: 'json' }, | ||
{ test: /\.jpe?g$|\.gif$|\.png|\.ico$/, | ||
loader: 'file?name=[name].[ext]' }, | ||
{ test: /\.eot$|\.ttf$|\.svg$|\.woff2?$/, | ||
loader: 'file?name=[name].[ext]' } ] }, | ||
plugins: | ||
[ { definitions: { 'process.env': { NODE_ENV: '"production"' } } }, | ||
{ filename: '[name].css', options: {}, id: 1 } ], | ||
devtool: 'source-map' | ||
} | ||
}, | ||
|
||
// for extra testing | ||
{ | ||
args: '', | ||
expected: { | ||
entry: { bundle: './docs/client.js' }, | ||
output: | ||
{ filename: '[name].js', | ||
path: './docs-built/assets', | ||
publicPath: '/assets/' }, | ||
externals: undefined, | ||
module: | ||
{ noParse: /babel-core\/browser/, | ||
loaders: | ||
[ { test: /\.js/, | ||
loader: 'babel', | ||
exclude: /node_modules|Samples\.js/ }, | ||
{ test: /Samples.js/, loader: 'transform?brfs!babel' }, | ||
{ test: /\.css/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css` }, | ||
{ test: /\.less$/, | ||
loader: `${root}node_modules/extract-text-webpack-plugin/loader.js?{"omit":1,"extract":true,"remove":true}!style!css!less` }, | ||
{ test: /\.json$/, loader: 'json' }, | ||
{ test: /\.jpe?g$|\.gif$|\.png|\.ico$/, | ||
loader: 'file?name=[name].[ext]' }, | ||
{ test: /\.eot$|\.ttf$|\.svg$|\.woff2?$/, | ||
loader: 'file?name=[name].[ext]' } ] }, | ||
plugins: | ||
[ { definitions: { 'process.env': { NODE_ENV: '"development"' } } }, | ||
{ filename: '[name].css', options: {}, id: 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,37 @@ | ||
/* eslint-env mocha */ | ||
|
||
import path from 'path'; | ||
import { inspect } from 'util'; | ||
import { spawn } from 'child-process-promise'; | ||
|
||
import buildConfCases from './buildConfSpec.js'; | ||
import testConfCases from './testConfSpec.js'; | ||
import docsConfCases from './docsConfSpec.js'; | ||
|
||
import { should } from 'chai'; | ||
should(); | ||
|
||
const webpackMock = path.join(__dirname, 'webpack-mock'); | ||
|
||
function runTests({ configFile, tests }) { | ||
describe('Webpack config', () => { | ||
tests.forEach((test) => { | ||
|
||
it(`should be equal to expected for "${configFile} ${test.args}"`, (done) => { | ||
spawn(webpackMock, [configFile, test.args], {capture: ['stdout', 'stderr']}) | ||
.then(({ stdout }) => { | ||
inspect(test.expected, {depth: null}).should.equal(stdout.trim()); | ||
done(); | ||
}) | ||
.fail(err => { | ||
done(err); | ||
}); | ||
}); | ||
|
||
}); | ||
}); | ||
} | ||
|
||
runTests(buildConfCases); | ||
runTests(testConfCases); | ||
runTests(docsConfCases); |
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,17 @@ | ||
export default { | ||
configFile: 'webpack/test.config.js', | ||
tests: [ | ||
// npm run test | ||
{ | ||
args: '', | ||
expected: { | ||
entry: undefined, | ||
output: { pathinfo: true }, | ||
externals: undefined, | ||
module: { loaders: [ { test: /\.js/, loader: 'babel', exclude: /node_modules/ } ] }, | ||
plugins: [ { definitions: { 'process.env': { NODE_ENV: '"development"' } } } ], | ||
devtool: 'eval' | ||
} | ||
} | ||
] | ||
}; |
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,35 @@ | ||
#!/usr/bin/env babel-node | ||
/* eslint no-process-exit: 0 */ | ||
import { inspect } from 'util'; | ||
import path from 'path'; | ||
|
||
/** | ||
* -p and --debug cannot be used by itself, | ||
* because they are legitimate options for `babel-node` | ||
*/ | ||
|
||
if (!process.argv[2]) { | ||
console.log('webpack-mock path_to_config <p, d>'); | ||
process.exit(0); | ||
} | ||
|
||
const pathOption = process.argv[2]; | ||
|
||
let argv; | ||
switch (process.argv[3]) { | ||
case 'p': | ||
argv = ['-p']; | ||
break; | ||
case 'd': | ||
argv = ['--debug']; | ||
break; | ||
default: | ||
argv = []; | ||
} | ||
|
||
/* clean args for sure */ | ||
process.argv = process.argv.slice(0, 2).concat(argv); | ||
|
||
const confFile = path.join(__dirname, '../../', pathOption); | ||
const configObject = require(confFile); | ||
console.log(inspect(configObject, { depth: null })); |