Skip to content

Commit

Permalink
cleanup for webpack, reorganize config
Browse files Browse the repository at this point in the history
  • Loading branch information
orizens committed Oct 16, 2016
1 parent 1815ab6 commit 7f5b399
Show file tree
Hide file tree
Showing 24 changed files with 265 additions and 224 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Expand Up @@ -38,7 +38,8 @@
"angular": true,
"inject": true,
"__dirname": true,
"gapi": true
"gapi": true,
"process": true
},
"extends": "eslint:recommended"
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion gulp/deploy.sh → config/deploy.sh
Expand Up @@ -2,7 +2,7 @@
if [ "$TRAVIS_BRANCH" == "master" ]; then
git config --global user.email "farhioren+travis@gmail.com"
git config --global user.name "travis-ci"
npm run release
npm run prod
cd dist
git init
git add .
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 0 additions & 27 deletions gulp/server.js

This file was deleted.

25 changes: 1 addition & 24 deletions gulpfile.babel.js
@@ -1,26 +1,3 @@
import gulp from 'gulp';
import runSequence from 'run-sequence';

// require external tasks
// import './gulp/assets.js';
// import './gulp/server.js';
import './gulp/test.js';
// import './gulp/watch.js';
// import './gulp/style.js';
// import './gulp/dist.js';
// import './gulp/e2e-test.js';
// import './gulp/browserify.js';
// import './gulp/dogen.js';

gulp.task('default', ['serve']);
gulp.task('serve', (callback) => {
runSequence(
// 'build',
'style',
'assets',
// 'build:vendors',
// 'browserify',
'watch'
// 'webserver'
);
});
import './config/dogen.js';
2 changes: 1 addition & 1 deletion karma.conf.js
Expand Up @@ -47,7 +47,7 @@ const options = {
}]
},
plugins: [
new ExtractTextPlugin('[name].[chunkhash].style.css'),
new ExtractTextPlugin('[name].[chunkhash].style.css')
],
resolve: {}
},
Expand Down
9 changes: 4 additions & 5 deletions package.json
Expand Up @@ -8,16 +8,15 @@
"pioneer": "node_modules/pioneer/bin/pioneer",
"e2e": "protractor protractor.conf.js",
"e2ed": "protractor debug protractor.conf.js",
"e2e:remote": "protractor ./gulp/config/protractor.conf.bs.js",
"e2e:remote": "protractor ./config/config/protractor.conf.bs.js",
"test": "NODE_ENV='test' karma start",
"testd": "DEBUG=true npm test",
"bdd": "NODE_ENV='test' BDD=true npm test",
"start": "NODE_ENV='dev' npm run dev",
"build": "gulp build && gulp build:vendors && gulp style",
"start": "NODE_ENV='development' npm run dev",
"wpw": "webpack -d --watch",
"dev": "webpack-dev-server --hot --inline --progress --colors --content-base src --port 9001",
"release": "rimraf dist/ && webpack --config=webpack.config.production.js -p",
"prod:serve": "lite-server -c gulp/prod-serve.json"
"prod": "rimraf dist/ && NODE_ENV='production' webpack --config=webpack.config.production.js -p",
"prod:serve": "lite-server -c config/prod-serve.json"
},
"repository": {
"type": "git",
Expand Down
14 changes: 0 additions & 14 deletions rollup.config.js

This file was deleted.

File renamed without changes.
91 changes: 91 additions & 0 deletions webpack.common.js
@@ -0,0 +1,91 @@
const path = require('path');
const webpack = require('webpack');
// const ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const getPath = (pathToFile) => path.resolve(__dirname, pathToFile);
const env = process.env.NODE_ENV || 'development';
// const envConfig = require('./config/environment/' + env + '.env');
const APP_NAME = 'echoes';

module.exports = {
entry: {
app: [
getPath('./src/app.js'),
getPath('./src/config/' + env + '.config.js')
],
vendors: [
'angular',
'angular-ui-router',
'angular-animate',
'angular-sanitize',
'angular-ui-bootstrap',
'angular-local-storage'
]
},
output: {
path: getPath('./dist'),
filename: '[name].[hash].bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules)/,
loaders: ['babel']
}, {
test: /\.html$/,
loader: 'ngtemplate!html',
exclude: /(index)/
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('css?sourceMap!less?sourceMap')
},
// FONTS
{
test: /\.woff$/,
loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
}, {
test: /\.eot$/,
loader: 'file'
}, {
test: /\.svg$/,
loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
},
// the url-loader uses DataUrls.
// the file-loader emits files.
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url?limit=10000&minetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file'
}]
},

plugins: [
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'APP_NAME': JSON.stringify(APP_NAME)
}),
// new webpack.DefinePlugin({
// 'APP_ENV': JSON.stringify(envConfig)
// }),
new webpack.optimize.CommonsChunkPlugin('vendors',
'[name].[hash].js'),
new webpack.optimize.AggressiveMergingPlugin({}),
new webpack.optimize.OccurenceOrderPlugin(true),
new ExtractTextPlugin('[name].[hash].style.css'),
// HtmlWebpackPlugin
// See: https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
template: 'html!./src/index.html'
}),
new CopyWebpackPlugin([
{
from: 'src/assets',
to: 'assets'
}
])
]
};
160 changes: 79 additions & 81 deletions webpack.config.js
@@ -1,82 +1,80 @@
const path = require('path');
const webpack = require('webpack');
const ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const getPath = (pathToFile) => path.resolve(__dirname, pathToFile);

module.exports = {
devtool: 'eval-source-map',
entry: {
app: [
getPath('./src/app.js'),
getPath('./src/config/dev.config.js')
],
vendors: [
'angular',
'angular-ui-router',
'angular-animate',
'angular-sanitize',
'angular-ui-bootstrap',
'angular-local-storage'
]
},
output: {
path: getPath('./dist'),
filename: '[name].[chunkhash].bundle.js',
sourceMapFilename: '[name].[chunkhash].bundle.map'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules)/,
loaders: ['babel']
}, {
test: /\.html$/,
loader: 'ngtemplate!html',
exclude: /(index)/
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('css?sourceMap!less?sourceMap')
},
// FONTS
{
test: /\.woff$/,
loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
}, {
test: /\.eot$/,
loader: 'file'
}, {
test: /\.svg$/,
loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
},
// the url-loader uses DataUrls.
// the file-loader emits files.
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url?limit=10000&minetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file'
}]
},

plugins: [
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new ngAnnotatePlugin({
add: true
// other ng-annotate options here
}),
new webpack.optimize.CommonsChunkPlugin('vendors',
'vendors.[hash].js'),
new ExtractTextPlugin('[name].[chunkhash].style.css'),
// HtmlWebpackPlugin
// See: https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
template: 'html!./src/index.html'
})
]
var webpackCommon = require('./webpack.common');
var webpackConfig = {
devtool: 'eval-source-map'
};
webpackCommon.devtool = webpackConfig.devtool;
module.exports = webpackCommon;
// module.exports = {
// devtool: 'eval-source-map',
// entry: {
// app: [
// getPath('./src/app.js'),
// getPath('./src/config/dev.config.js')
// ],
// vendors: [
// 'angular',
// 'angular-ui-router',
// 'angular-animate',
// 'angular-sanitize',
// 'angular-ui-bootstrap',
// 'angular-local-storage'
// ]
// },
// output: {
// path: getPath('./dist'),
// filename: '[name].[chunkhash].bundle.js',
// sourceMapFilename: '[name].[chunkhash].bundle.map'
// },
// module: {
// loaders: [{
// test: /\.js$/,
// exclude: /(node_modules)/,
// loaders: ['babel']
// }, {
// test: /\.html$/,
// loader: 'ngtemplate!html',
// exclude: /(index)/
// }, {
// test: /\.less$/,
// loader: ExtractTextPlugin.extract('css?sourceMap!less?sourceMap')
// },
// // FONTS
// {
// test: /\.woff$/,
// loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
// }, {
// test: /\.eot$/,
// loader: 'file'
// }, {
// test: /\.svg$/,
// loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
// },
// // the url-loader uses DataUrls.
// // the file-loader emits files.
// {
// test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
// loader: 'url?limit=10000&minetype=application/font-woff'
// }, {
// test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
// loader: 'file'
// }]
// },

// plugins: [
// new webpack.DefinePlugin({
// 'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
// }),
// new ngAnnotatePlugin({
// add: true
// // other ng-annotate options here
// }),
// new webpack.optimize.CommonsChunkPlugin('vendors',
// 'vendors.[hash].js'),
// new ExtractTextPlugin('[name].[chunkhash].style.css'),
// // HtmlWebpackPlugin
// // See: https://github.com/ampedandwired/html-webpack-plugin
// new HtmlWebpackPlugin({
// template: 'html!./src/index.html'
// })
// ]
// };

0 comments on commit 7f5b399

Please sign in to comment.