-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
2c52084
commit 013ae22
Showing
8 changed files
with
178 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"presets": [ | ||
"env", | ||
"react", | ||
"stage-1" | ||
], | ||
"plugins": [ | ||
], | ||
"env": { | ||
"production": { | ||
"plugins": [ | ||
"transform-react-constant-elements", | ||
"transform-react-remove-prop-types", | ||
"transform-object-rest-spread" | ||
] | ||
} | ||
} | ||
} |
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 @@ | ||
node_modules | ||
lib | ||
|
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 @@ | ||
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
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,44 @@ | ||
// More info on Webpack's Node API here: https://webpack.github.io/docs/node.js-api.html | ||
// Allowing console calls below since this is a build file. | ||
/* eslint-disable no-console */ | ||
const chalk = require('chalk'); | ||
const webpack = require('webpack'); | ||
const config = require('../webpack.config.prod'); | ||
|
||
const chalkConfig = { | ||
chalkError: chalk.red, | ||
chalkSuccess: chalk.green, | ||
chalkWarning: chalk.yellow, | ||
chalkProcessing: chalk.blue, | ||
}; | ||
|
||
const { chalkError, chalkSuccess, chalkWarning, chalkProcessing } = chalkConfig; | ||
|
||
process.env.NODE_ENV = 'production'; // this assures React is built in prod mode and that the Babel dev config doesn't apply. | ||
|
||
console.log(chalkProcessing('Generating minified bundle. This will take a moment...')); | ||
|
||
webpack(config).run((error, stats) => { | ||
if (error) { // so a fatal error occurred. Stop here. | ||
console.log(chalkError(error)); | ||
return 1; | ||
} | ||
|
||
const jsonStats = stats.toJson(); | ||
|
||
if (jsonStats.hasErrors) { | ||
return jsonStats.errors.map(error => console.log(chalkError(error))); | ||
} | ||
|
||
if (jsonStats.hasWarnings) { | ||
console.log(chalkWarning('Webpack generated the following warnings: ')); | ||
jsonStats.warnings.map(warning => console.log(chalkWarning(warning))); | ||
} | ||
|
||
console.log(`Webpack stats: ${stats}`); | ||
|
||
// if we got this far, the build succeeded. | ||
console.log(chalkSuccess('Your app is compiled in production mode in /lib. It\'s ready to roll!')); | ||
|
||
return 0; | ||
}); |
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,51 @@ | ||
'use strict'; | ||
|
||
const webpack = require('webpack'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
externals: [ | ||
{ | ||
'react-dom': { | ||
root: 'ReactDOM', | ||
commonjs2: 'react-dom', | ||
commonjs: 'react-dom', | ||
amd: 'react-dom' | ||
}, | ||
}, | ||
{ | ||
react: { | ||
root: 'React', | ||
commonjs2: 'react', | ||
commonjs: 'react', | ||
amd: 'react', | ||
}, | ||
}, | ||
], | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json'], | ||
modules: [ | ||
'node_modules', | ||
path.join(__dirname, 'src'), | ||
], | ||
}, | ||
devtool: 'source-map', | ||
entry: './src/index.js', | ||
output: { | ||
filename: 'index.js', | ||
library: 'react-rbac-guard', | ||
libraryTarget: 'umd', | ||
path: path.resolve(__dirname, 'lib'), | ||
umdNamedDefine: true, | ||
}, | ||
module: { | ||
rules: | ||
[ | ||
{ | ||
test: /\.jsx$/, | ||
exclude: /node_modules/, | ||
loader: ['babel-loader'], | ||
}, | ||
], | ||
}, | ||
}; |