Skip to content

Instantly share code, notes, and snippets.

@falexandre
Created January 24, 2017 09:13
Show Gist options
  • Save falexandre/9e4a49f25973bc5d71aedc9d63047ad6 to your computer and use it in GitHub Desktop.
Save falexandre/9e4a49f25973bc5d71aedc9d63047ad6 to your computer and use it in GitHub Desktop.
web-pac exemple
{
"name": "gestaoponto-frontend",
"version": "1.0.0",
"description": "GPO - Gestão do Ponto",
"scripts": {
"build": "rimraf dist && webpack --bail --progress --profile",
"server": "webpack-dev-server --history-api-fallback --inline --progress --host 0.0.0.0 --port 3000",
"test": "karma start",
"test-watch": "karma start --auto-watch --no-single-run",
"start": "npm run server"
},
"author": "Senior Sistemas S/A",
"dependencies": {
"angular": "^1.5.0",
"angular-bootstrap-datetimepicker": "^1.1.3",
"angular-date-time-input": "^1.2.1",
"angular-chart.js": "^1.0.0",
"angular-messages": "^1.5.7",
"angular-moment": "^1.0.0-beta.6",
"angular-sanitize": "^1.5.5",
"angular-toastr": "^1.7.0",
"angular-translate": "^2.11.0",
"angular-ui-mask": "^1.8.5",
"angular-ui-router": "^0.2.18",
"angulartics": "^1.0.3",
"angulartics-google-analytics": "^0.2.0",
"bootstrap": "^3.3.6",
"bootstrap-select": "^1.10.0",
"chart.js": "^2.2.1",
"jquery": "^1.12.3",
"jquery.uniform": "^2.2.2",
"moment": "^2.13.0",
"ng-dialog": "^0.6.2",
"ng-file-upload": "^12.0.4",
"satellizer": "^0.14.0",
"ui-select": "^0.18.1"
},
"devDependencies": {
"angular-mocks": ">=1.5.0",
"autoprefixer": ">=6.0.3",
"babel-core": ">=6.2.1",
"babel-loader": ">=6.2.0",
"babel-plugin-transform-es2015-classes": ">=6.9.0",
"babel-preset-es2015": ">=6.1.18",
"copy-webpack-plugin": ">=1.1.1",
"css-loader": ">=0.23.0",
"extract-text-webpack-plugin": ">=1.0.1",
"file-loader": ">=0.8.5",
"html-webpack-plugin": ">=2.7.1",
"imports-loader": ">=0.6.5",
"isparta-instrumenter-loader": ">=1.0.0",
"isparta-loader": ">=2.0.0",
"jasmine-core": ">=2.3.4",
"karma": ">=0.13.14",
"karma-coverage": ">=0.5.3",
"karma-jasmine": ">=0.3.6",
"karma-phantomjs-launcher": ">=1.0.0",
"karma-sourcemap-loader": ">=0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": ">=1.7.0",
"node-libs-browser": ">=1.0.0",
"node-sass": ">=3.4.2",
"null-loader": ">=0.1.1",
"phantomjs": ">=2.1.7",
"phantomjs-prebuilt": ">=2.1.4",
"postcss-loader": ">=0.8.0",
"raw-loader": ">=0.5.1",
"rimraf": ">=2.5.1",
"sass-loader": ">=3.2.0",
"script-loader": ">=0.6.1",
"style-loader": ">=0.13.0",
"webpack": ">=1.12.13",
"webpack-dev-server": ">=1.14.1"
}
}
'use strict';
// Modules
var path = require('path'),
webpack = require('webpack'),
autoprefixer = require('autoprefixer'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin');
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
var isProduction = ENV === 'build';
var plugins = [
new webpack.ProvidePlugin({
'$': 'jquery',
'jQuery': 'jquery',
'window.jQuery': 'jquery'
})
];
if (!isTest) {
plugins.push(
new HtmlWebpackPlugin({
template: './app/index.html'
}),
new ExtractTextPlugin(isProduction ? '[name].[hash].css' : '[name].css', {disable: isTest})
)
}
if (isProduction) {
plugins.push(
new webpack.NoErrorsPlugin(),
// This plugin looks for similar chunks and files and merges them for better caching by the user
new webpack.optimize.DedupePlugin(),
// This plugin prevents Webpack from creating chunks that would be too small to be worth loading separately
new webpack.optimize.MinChunkSizePlugin({
minChunkSize: 5120 // ~50kb
}),
new webpack.optimize.UglifyJsPlugin(),
new CopyWebpackPlugin([{
from: __dirname + '/app/assets',
to: 'assets/'
}], {
ignore: ['*.scss']
})
)
}
var modulePreLoaders = [];
if (isTest) {
modulePreLoaders.push({
test: /\.js$/,
exclude: [
/node_modules/,
/\.spec\.js$/
],
loader: 'isparta-instrumenter'
})
}
var devtool = /*'eval-source-map'*/ 'source-map';
if (isTest) {
devtool = 'inline-source-map';
} else if (isProduction) {
devtool = 'hidden-source-map';
}
module.exports = {
entry: isTest ? {} : {
app: './app/src/main.js',
vendors: []
},
output: isTest ? {} : {
path: __dirname + '/dist',
publicPath: isProduction ? '/' : 'http://localhost:3000/',
filename: isProduction ? '[name].[hash].js' : '[name].bundle.js',
chunkFilename: isProduction ? '[name].[hash].js' : '[name].bundle.js'
},
devtool: devtool,
plugins: plugins,
module: {
preLoaders: modulePreLoaders,
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: isTest ? 'null' : ExtractTextPlugin.extract('style', 'css?sourceMap!postcss')
},
{
test: /\.scss$/,
loader: isTest ? 'null' : ExtractTextPlugin.extract('style', 'css!sass')
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
loader: 'file-loader?name=assets/images/[name].[ext]'
},
{
test: /\.(woff|woff2|ttf|eot)$/,
loader: 'file-loader?name=assets/fonts/[name].[ext]'
},
{
test: require.resolve("jquery"),
loader: "imports?define=>false"
},
{
test: /\.html$/,
loader: 'raw'
}]
},
devServer: {
contentBase: './app/',
stats: 'minimal'
},
resolve: {
root: [
path.join(__dirname, 'app', 'assets'),
path.resolve(__dirname)
],
extensions: ['.js', '.scss', '.png', '.jpg', ''],
alias: {
modules: 'app/src/modules'
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment