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

Upgrade to Webpack 3 #10279

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great change too 😄

}
}]
],
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",
Copy link
Contributor

@gyandeeps gyandeeps Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already old 😄 ... latest is 3.5.3

"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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should update it to 7.1 to match webpack3. current version (6.2.0) only matches 1.x and 2.x (with deprecation warnings)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgraded

},
{
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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wrote for me. maybe put in .gitignore? or maybe it will be needed eventually due to hash changes?

also having Content not from webpack is served from /Users/cezaraugusto/dev/browser-laptop/app/extensions/brave, is that expected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, I will add to .gitignore.

that is expected and the same behavior as before (content base was previously set via --content-base=./app/extensions/brave" in the webpack-dev-server params)

}
return merged
}

Expand Down