Skip to content

Commit

Permalink
Add babel-runtime-plugin, fix dist clean bug and
Browse files Browse the repository at this point in the history
add a nominify option to the build command
  • Loading branch information
geowarin committed May 9, 2016
1 parent 703804a commit d024d61
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/babel/createBabelConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = function createBabelConfig (context, isWebpack) {
],
plugins: [
[require.resolve('babel-plugin-module-alias'), context.userConfig.aliases],
[require.resolve('babel-plugin-transform-decorators-legacy')]
[require.resolve('babel-plugin-transform-decorators-legacy')],
[require.resolve('babel-plugin-transform-runtime')]
],
env: {
development: {
Expand Down
1 change: 0 additions & 1 deletion lib/bin/tarec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const Commands = require('../commands/Commands');

const rootDir = path.join(__dirname, '../..');
const projectDir = process.cwd();
const distFolder = path.join(projectDir, 'dist');

const userConfig = loadUserConfig(projectDir);

Expand Down
14 changes: 12 additions & 2 deletions lib/commands/addBuiltInCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ const chalk = require('chalk');

module.exports = function addBuiltInCommands (commands) {
commands.addCommandHelp('build', `Generate your bundled application in ${chalk.magenta('/dist')}`);
commands.addPreCommand('build', (context) => {
commands.addPreCommand('build', (context, args) => {
process.env['NODE_ENV'] = 'production';
context.webpackConfig = require('../webpack/webpack.prod.config')(context);
if (args.nominify !== true) {
context.webpackConfig.module.loaders.push(new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
screw_ie8: true
}
}))
}
});
commands.addCommand('build', (context, args) => {
require('../commands/clean')(context.distFolder, args);
require('../commands/clean')(context);
require('../commands/build')(context, args);
});

Expand Down
5 changes: 3 additions & 2 deletions lib/commands/clean.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

const del = require('del');
const path = require('path');

module.exports = function clean(distFolder) {
del.sync(distFolder);
module.exports = function clean(context) {
del.sync(path.join(context.projectDir, 'dist'));
};
8 changes: 0 additions & 8 deletions lib/webpack/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ module.exports = function prodConfig (context) {
title: 'ReactApp',
template: context.indexPath
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
screw_ie8: true
}
}),
new ExtractTextPlugin('[name]-[hash].css'),
new CopyWebpackPlugin(
[
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"babel-plugin-module-alias": "^1.4.0",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.7.5",
"babel-plugin-transform-runtime": "^6.8.0",
"babel-preset-es2015-webpack": "^6.4.1",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
Expand Down

0 comments on commit d024d61

Please sign in to comment.