Skip to content

Commit

Permalink
Merge pull request #2 from mike-esokia/PHRAS-1540_update_webpack_and_…
Browse files Browse the repository at this point in the history
…dependencies

PHRAS-1540 update webpack and dependencies
  • Loading branch information
nmaillat authored Nov 16, 2017
2 parents 1cdbe29 + 1d0e16f commit a309148
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 94 deletions.
4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const _root = __dirname + '/../';

module.exports = {

// path helpers
// path helpers
_app: 'common',
minified: 'common.min.js',
dev: 'common.js',
Expand All @@ -12,4 +12,4 @@ module.exports = {
testDir: _root + 'tests',
setupDir: _root + 'tests/setup/node.js',
karmaConf: _root + 'config/karma.conf.js'
};
};
50 changes: 28 additions & 22 deletions config/webpack/webpack.development.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ module.exports = {
// entry points
entry: config.sourceDir,
cache: true,
debug: true,
watch: true,
devtool: 'eval',
output: {
Expand All @@ -74,24 +73,27 @@ module.exports = {
library: config._app
},
module: {
preLoaders: [{
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
}],
loaders: [{
test: /[\/\\]src[\/\\]vendors[\/\\]jquery\.contextmenu_custom\.js$/,
loader: "imports?define=>false"
},
{
test: /\.js$/,
exclude: /node_modules/,
include: path.join(__dirname, '../../src'),
loader: 'babel-loader'
}]
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /[\/\\]src[\/\\]vendors[\/\\]jquery\.contextmenu_custom\.js$/,
use: "imports-loader?define=>false"
},
{
test: /\.js$/,
exclude: /node_modules/,
include: path.join(__dirname, '../../src'),
use: 'babel-loader'
}
]
},
resolve: {
extensions: ['', '.js'],
extensions: ['*', '.js'],
alias: {
'jquery-contextmenu': path.join(__dirname, '../../src/vendors/jquery.contextmenu_custom.js')
}
Expand All @@ -100,13 +102,20 @@ module.exports = {
new WebpackNotifierPlugin({
alwaysNotify: true
}),
new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.BannerPlugin(banner),
new webpack.DefinePlugin({
'__DEV__': true,
'process.env.NODE_ENV': JSON.stringify('development'),
VERSION: JSON.stringify(pkg.version)
})
}),
new webpack.LoaderOptionsPlugin({
debug: true,
options: {
eslint: {
configFile: config.eslintDir
}
}
}),
],
externals: {
'jquery': {
Expand All @@ -115,8 +124,5 @@ module.exports = {
commonjs: 'jquery',
amd: 'jquery'
}
},
eslint: {
configFile: config.eslintDir
}
};
11 changes: 3 additions & 8 deletions config/webpack/webpack.hot.assets.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ const WebpackDevServer = require('webpack-dev-server');
const environment = require('../environment');
const config = require('./webpack.development.config');

config.entry = [
// For hot style updates
'webpack/hot/only-dev-server',
// The script refreshing the browser on none hot updates
'webpack-dev-server/client?http://localhost:8080'
].concat(config.entry);
config.devServer = {
hot: true
}

config.plugins = [
// Used for hot-reload
Expand All @@ -21,14 +18,12 @@ config.plugins = [
new WebpackDevServer(webpack(config), {
publicPath: 'http://localhost:8080/assets/',
// Configure hot replacement
hot: true,
// The rest is terminal configurations
quiet: false,
noInfo: true,
historyApiFallback: {
index: './templates/index.html'
},
progress: true,
stats: {
colors: true
}
Expand Down
36 changes: 21 additions & 15 deletions config/webpack/webpack.karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ import config from '../config';

module.exports = {
cache: true,
debug: true,
hot:false,
output: {},
entry: {},
module: {
postLoaders: [{
test: /\.js$/,
include: path.resolve('src/'),
loader: 'istanbul-instrumenter'
}],
loaders: [{
test: /\.js?$/,
exclude: /node_modules/,
loaders: ['babel-loader']
}]
rules: [{
test: /\.js$/,
enforce: 'post',
include: path.resolve('src/'),
loader: 'istanbul-instrumenter-loader'
},
{
test: /\.js?$/,
exclude: /node_modules/,
use: ['babel-loader']
}
]
},
resolve: {
extensions: ['', '.js']
extensions: ['*', '.js']
},
externals: {
jquery: 'jQuery',
humane: 'humane'
},
plugins: []
plugins: [
new webpack.LoaderOptionsPlugin({
debug: true
}),
],
devServer: {
hot: true
}
};
13 changes: 7 additions & 6 deletions config/webpack/webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const webpackConfig = require('./webpack.development.config')
module.exports = Object.assign({}, webpackConfig, {

cache: false,
debug: false,
devtool: false,
hot: false,
build: true,
watch: false,
output: {
path: config.distDir,
Expand All @@ -33,14 +30,18 @@ module.exports = Object.assign({}, webpackConfig, {
title: PKG_LOCATION.name,
alwaysNotify: true
}),
new webpack.LoaderOptionsPlugin({
debug: true
}),
// optimizations
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'__DEV__': false,
'process.env.NODE_ENV': JSON.stringify('production'),
VERSION: JSON.stringify(PKG_LOCATION.version)
})
]
],
devServer: {
hot: true
}
});
16 changes: 8 additions & 8 deletions config/webpack/webpack.production.minified.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const webpackConfig = require('./webpack.development.config')
module.exports = Object.assign({}, webpackConfig, {

cache: false,
debug: false,
devtool: false,
hot: false,
build: true,
watch: false,
output: {
path: config.distDir,
Expand All @@ -33,9 +30,6 @@ module.exports = Object.assign({}, webpackConfig, {
title: PKG_LOCATION.name,
alwaysNotify: true
}),
// optimizations
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
output: {
Expand All @@ -52,6 +46,12 @@ module.exports = Object.assign({}, webpackConfig, {
'__DEV__': false,
'process.env.NODE_ENV': JSON.stringify('production'),
VERSION: JSON.stringify(PKG_LOCATION.version)
})
]
}),
new webpack.LoaderOptionsPlugin({
debug: true
}),
],
devServer: {
hot: true
}
});
65 changes: 32 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phraseanet-common",
"version": "0.3.2",
"version": "0.4.0",
"description": "Phraseanet frontend shared libraries",
"scripts": {
"clean": "rimraf dist",
Expand Down Expand Up @@ -64,36 +64,35 @@
"eslint-config-airbnb": "^4.0.0",
"eslint-loader": "^1.2.1",
"eslint-plugin-react": "^3.16.1",
"istanbul-instrumenter-loader": "^0.1.3",
"karma": "^0.13.19",
"istanbul-instrumenter-loader": "^3.0.0",
"karma": "^1.7.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.2.2",
"karma-cli": "^0.1.2",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.7",
"karma-ie-launcher": "^0.2.0",
"karma-mocha": "^0.2.1",
"karma-mocha-reporter": "^1.1.5",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sinon": "^1.0.4",
"karma-sinon-chai": "^1.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon": "^1.0.5",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.23",
"karma-webpack": "^1.7.0",
"lodash": "4.0.1",
"mocha": "^2.4.5",
"npm-check-updates": "^2.5.7",
"npmlog": "^2.0.2",
"phantomjs": "^2.1.3",
"phantomjs-polyfill": "0.0.1",
"phantomjs-prebuilt": "^2.1.3",
"pre-commit": "^1.1.2",
"rimraf": "^2.5.1",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"webpack": "^1.12.12",
"webpack-dev-server": "^1.14.1",
"webpack-notifier": "1.2.1"
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.4",
"lodash": "4.17.4",
"mocha": "^3.5.0",
"npm-check-updates": "^2.12.1",
"npmlog": "^4.1.2",
"phantomjs-polyfill": "0.0.2",
"phantomjs-prebuilt": "^2.1.14",
"pre-commit": "^1.2.2",
"rimraf": "^2.6.1",
"sinon": "^2.1.0",
"sinon-chai": "^2.12.0",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1",
"webpack-notifier": "^1.5.0"
},
"babel": {
"ignore": [
Expand All @@ -113,11 +112,11 @@
"homepage": "https://github.com/lostdalek/Phraseanet-common",
"license": "MIT",
"dependencies": {
"es6-promise": "^3.0.2",
"es6-promise": "^4.1.1",
"humane-js": "^3.2.2",
"imports-loader": "^0.6.5",
"jquery": "^1.11.3",
"imports-loader": "^0.7.1",
"jquery": "^3.2.1",
"js-cookie": "^2.1.0",
"pym.js": "^0.4.5"
"pym.js": "^1.3.1"
}
}

0 comments on commit a309148

Please sign in to comment.