Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Switch to webpack 3, switch babel to chromium 60
Browse files Browse the repository at this point in the history
  • Loading branch information
gyandeeps authored and evq committed Aug 14, 2017
1 parent ac8a6df commit 28e575d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"react",
["env", {
"targets": {
"chrome": 57
"chrome": 60
}
}]
],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dist-ia32
win64-dist
Brave.tar.bz2

app/extensions/gen
app/extensions/brave/gen
app/extensions/torrent/gen
*.pfx
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"vagrant-rsync-linux": "VAGRANT_CWD=./test/vms/vagrant/ubuntu-14.04 vagrant rsync-auto",
"vagrant-ssh-linux": "VAGRANT_CWD=./test/vms/vagrant/ubuntu-14.04 vagrant ssh",
"vagrant-up-linux": "VAGRANT_CWD=./test/vms/vagrant/ubuntu-14.04 vagrant up",
"watch": "webpack-dev-server --inline --hot --colors --content-base=./app/extensions/brave",
"watch": "webpack-dev-server --color",
"watch-all": "npm run watch & npm run watch-test",
"watch-test": "cross-env NODE_ENV=test webpack --watch",
"webpack": "webpack",
Expand Down Expand Up @@ -130,7 +130,7 @@
"asar": "^0.11.0",
"babel": "^6.1.18",
"babel-core": "^6.3.15",
"babel-loader": "^6.2.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-react-constant-elements": "^6.4.0",
"babel-plugin-transform-react-inline-elements": "^6.4.0",
"babel-polyfill": "^6.3.14",
Expand Down Expand Up @@ -181,11 +181,11 @@
"spectron": "brave/spectron#chromium60",
"standard": "9.0.0",
"style-loader": "^0.13.0",
"uglify-js-harmony": "^2.7.5",
"uglifyjs-webpack-plugin": "^1.0.0-beta.2",
"uuid": "^3.0.1",
"webdriverio": "4.7.1",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0",
"webpack": "~3.4.1",
"webpack-dev-server": "~2.6.1",
"webpack-notifier": "^1.2.1",
"xml2js": "^0.4.15"
},
Expand Down
41 changes: 24 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function config () {
devtool: '#source-map',
cache: true,
module: {
loaders: [
rules: [
{
test: /\.js?$/,
exclude: [
Expand All @@ -23,7 +23,7 @@ function config () {
path.resolve(__dirname, 'app', 'browser', '*'),
path.resolve(__dirname, 'app', 'extensions', '*')
],
loader: 'babel'
loader: 'babel-loader'
},
{
test: /\.less$/,
Expand All @@ -33,10 +33,6 @@ function config () {
test: /\.css$/,
loader: 'style-loader!css-loader?-minimize'
},
{
test: /\.json$/,
loader: 'json'
},
// Loads font files for Font Awesome
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
Expand All @@ -49,7 +45,7 @@ function config () {
]
},
resolve: {
extensions: ['', '.js', '.jsx']
extensions: ['.js', '.jsx']
},
externals: {
'electron': 'chrome'
Expand Down Expand Up @@ -89,7 +85,11 @@ function watchOptions () {

function development () { // eslint-disable-line
var dev = config()
dev.plugins.push(new webpack.HotModuleReplacementPlugin())
dev.devServer = {
contentBase: path.resolve(__dirname, 'app', 'extensions', 'brave'),
hot: true,
inline: true,
publicPath: 'http://localhost:' + port + '/gen/',
headers: { 'Access-Control-Allow-Origin': '*' }
}
Expand All @@ -98,15 +98,17 @@ function development () { // eslint-disable-line

function production () { // eslint-disable-line
var prod = config()
prod.plugins.push(new webpack.optimize.DedupePlugin())
var UglifyJsPlugin = require('uglifyjs-webpack-plugin')
prod.plugins.push(new webpack.optimize.OccurrenceOrderPlugin(true))
if (env !== 'test') {
prod.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
mangle: {
except: ['module', 'exports', 'require']
prod.plugins.push(new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
},
mangle: {
reserved: ['module', 'exports', 'require']
}
}
}))
}
Expand All @@ -117,9 +119,14 @@ function test () { // eslint-disable-line
return Object.assign(production(), watchOptions())
}

function merge (config, env) {
var merged = Object.assign({}, env, config)
merged.plugins = (config.plugins || []).concat(env.plugins || [])
function merge (config, envConfig) {
var merged = Object.assign({}, envConfig, config)
merged.plugins = (config.plugins || []).concat(envConfig.plugins || [])
// In development we overwrite the output path so the dev server serves everything from the gen subdir
if (env === 'development') {
// Note that this directory will never be created since the dev server does not write out to files
merged.output.path = path.resolve(__dirname, 'app', 'extensions', 'gen')
}
return merged
}

Expand Down

0 comments on commit 28e575d

Please sign in to comment.