Last active
April 26, 2017 04:13
-
-
Save henricavalcante/e969b5a4b1d43f8238fe53a6c86e6d04 to your computer and use it in GitHub Desktop.
Webpack + AngularJS Boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "repo", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "webpack --config webpack.build.js --bail -p", | |
"deploy": "webpack --config webpack.build.js --bail -p && firebase deploy", | |
"dev": "node_modules/.bin/webpack-dev-server --history-api-fallback --hot --inline --progress" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/henricavalcante/repo.git" | |
}, | |
"keywords": [], | |
"author": "Henri Cavalcante", | |
"license": "ISC", | |
"bugs": { | |
"url": "https://github.com/henricavalcante/repo/issues" | |
}, | |
"homepage": "https://github.com/henricavalcante/repo", | |
"dependencies": { | |
"angular": "^1.5.7", | |
"angular-input-masks": "^2.5.0", | |
"angular-sanitize": "^1.5.8", | |
"angular-ui-bootstrap": "^2.0.1", | |
"angular-ui-router": "^0.3.1", | |
"autoprefixer-core": "^6.0.1", | |
"babel-core": "^6.10.4", | |
"babel-loader": "^6.2.4", | |
"babel-preset-es2015": "^6.9.0", | |
"babel-preset-stage-2": "^6.11.0", | |
"babel-runtime": "^6.9.2", | |
"bootstrap": "^3.3.7", | |
"css-loader": "^0.23.1", | |
"extract-text-webpack-plugin": "^1.0.1", | |
"file-loader": "^0.9.0", | |
"firebase": "^3.2.1", | |
"html-webpack-plugin": "^2.22.0", | |
"node-libs-browser": "^1.0.0", | |
"postcss-loader": "^0.9.1", | |
"raw-loader": "^0.5.1", | |
"style-loader": "^0.13.1", | |
"webpack": "^1.13.1", | |
"webpack-dev-server": "^1.14.1", | |
"whatwg-fetch": "^1.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = require('./webpack')({ | |
BUILD: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = require('./webpack')({ | |
BUILD: false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var webpack = require('webpack'); | |
var autoprefixer = require('autoprefixer-core'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = function makeWebpackConfig(options) { | |
var BUILD = !!options.BUILD; | |
var config = {}; | |
config.entry = { | |
app: './src/app.js' | |
} | |
config.output = { | |
path: __dirname + '/dist/', | |
publicPath: BUILD ? '' : 'http://localhost:8080/', | |
filename: BUILD ? '[name].[hash].js' : '[name].bundle.js', | |
chunkFilename: BUILD ? '[name].[hash].js' : '[name].bundle.js' | |
} | |
config.devtool = 'eval'; | |
config.module = { | |
preLoaders: [], | |
loaders: [{ | |
test: /\.js$/, | |
loader: 'babel', | |
exclude: /node_modules/, | |
query: { | |
cacheDirectory: true, | |
presets: ['es2015', 'stage-2'] | |
} | |
}, { | |
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/, | |
loader: 'file' | |
}, { | |
test: /\.html$/, | |
loader: 'raw' | |
},{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract('style', 'css?sourceMap!postcss') | |
}] | |
}; | |
config.postcss = [ | |
autoprefixer({ | |
browsers: ['last 2 version'] | |
}) | |
]; | |
config.plugins = [ | |
new ExtractTextPlugin('[name].[hash].css', { | |
disable: !BUILD | |
}), | |
new HtmlWebpackPlugin({ | |
template: './src/index.html', | |
inject: 'body', | |
minify: false | |
}) | |
]; | |
if (BUILD) { | |
config.plugins.push( | |
new webpack.NoErrorsPlugin(), | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.UglifyJsPlugin() | |
) | |
} | |
config.devServer = { | |
contentBase: './dist', | |
stats: { | |
modules: false, | |
cached: false, | |
colors: true, | |
chunk: false | |
} | |
}; | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment