- module declarations
- export object, function or variable
- import/require dependency
- native module implementation - no support
- all declarations (and vendor libraries) goes to global scope
- polyfill for wrapping client code and separating scopes
- RequireJS
- CommonJS
- AMD (Asynchronous Module Definition)
- NPM + Browserify
- ES6/7 Modules
- SystemJS
- Webpack
npm install webpack -g
npm install webpack
webpack.config.js
entry: {
index: './app/frontend/javascripts/index.js'
},
output: {
filename: '[name]-[hash].js',
path: './public/assets/'
},
resolve: {
extensions: ['', '.js']
},{
entry: {
app: './src/app.js',
search: './src/search.js'
},
output: {
filename: '[name].js',
path: __dirname + '/built'
}
} module: {
loaders: [
{ test: /\.js/, loaders: ['uglify', 'ng-annotate']},
{ test: /\.slm/, loaders: ["template-html-loader"]},
{ test: /\.coffee$/, loader: "coffee" }
],
},
plugins: [
new AssetsPlugin({
path: path.join(__dirname, 'public', 'assets'),
filename: 'assets.json'
}),
new Clean(['./public/assets/'])
]
loaders: [
{ test: /\.js/, loaders: ['babel'] },
],
npm install --save babel-loader
"scripts": {
"webpack_watch": "webpack --watch",
"webpack": "webpack"
},
webpack --watch
package.json
var path = require("path");
module.exports = {
entry: {
app: ["./app/main.js"]
},
output: {
path: path.resolve(__dirname, "build"),
publicPath: "/assets/",
filename: "bundle.js"
}
};$ webpack-dev-server --content-base build/
"postinstall":
"if [ \"$NODE_ENV\" = \"\"production\"\" ];
then webpack -p --profile --config webpack-prod.config.js; "
Or wait for more presentations