Skip to content

Instantly share code, notes, and snippets.

@biswajitpaul01
Last active December 19, 2017 06:30
Show Gist options
  • Save biswajitpaul01/4d70c4f37e861444723e59c792321bff to your computer and use it in GitHub Desktop.
Save biswajitpaul01/4d70c4f37e861444723e59c792321bff to your computer and use it in GitHub Desktop.
# Serve from current directory without Babel-JS & Webpack
> browser-sync start --proxy "127.0.0.1" --directory --files "**/*"
# Babel JS
> npm install webpack -g
> npm init
> npm install webpack --save-dev
> webpack assets/js/app.js assets/js/app.bundle.js [Part 1]
> npm install babel-core babel-loader babel-preset-env --save-dev
# Create root file: .babelrc
{ "presets": [ "env" ] }
# Browsersync with webpack
> npm install browser-sync-webpack-plugin --save-dev
# Create root file: webpack.config.js
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: './assets/js/app.js',
output: {
filename: './assets/js/app.compiled.js'
},
watch: true,
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
proxy: "127.0.0.1",
files: "**/*"
}),
new UglifyJsPlugin({
test: /\.js($|\?)/i
})
],
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: [
/node_modules/
]
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment