13. /features/pre-compile
module.exports = {
entry: [
'./src/js/index.js'
],
output: {
filename: './dist/bundle.js'
},
module: {
loaders: [
{
test: /.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
};
class Stark {
constructor(name) {
this.name = name;
}
};
const sansa = new Stark('Sansa');
const tony = new Stark('Tony');
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof
Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Stark = function Stark(name) {
_classCallCheck(this, Stark);
this.name = name;
};
;
var sansa = new Stark('Sansa');
var tony = new Stark('Tony');
19. /takeaway
• Reduce number of files to load in the browser
• Use latest Javascript version
• Include in the build libraries from npm
• Minify and obfuscate Javascript code
• Use style pre-processors
• Reduce images file size
• Code linting
• Develop faster via browser-webpack sync