Skip to content

Commit

Permalink
Fixes #19478 - migrate to webpack2
Browse files Browse the repository at this point in the history
  • Loading branch information
matanw authored and matanw committed May 9, 2017
1 parent 7bc914e commit eb7c1ef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
39 changes: 24 additions & 15 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');

// must match config.webpack.dev_server.port
var devServerPort = 3808;

// set TARGETNODE_ENV=production on the environment to add asset fingerprints
var production = process.env.RAILS_ENV === 'production' || process.env.NODE_ENV === 'production';
var production =
process.env.RAILS_ENV === 'production' ||
process.env.NODE_ENV === 'production';

var config = {
entry: {
// Sources are expected to live in $app_root/webpack
'bundle': './webpack/assets/javascripts/bundle.js'
bundle: './webpack/assets/javascripts/bundle.js'
},

output: {
Expand All @@ -30,8 +32,10 @@ var config = {
},

resolve: {
extensions: ['', '.js'],
root: path.join(__dirname, '..', 'webpack')
modules: [
path.join(__dirname, '..', 'webpack'),
path.join(__dirname, '..', 'node_modules')
]
},

module: {
Expand All @@ -43,18 +47,21 @@ var config = {
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /(\.png|\.gif)$/,
loader: "url-loader?limit=32767"
loader: 'url-loader?limit=32767'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style-loader', // The backup style loader
'css-loader?sourceMap!sass-loader?sourceMap'
)
loader: ExtractTextPlugin.extract({
fallback: 'style-loader', // The backup style loader
use: 'css-loader?sourceMap!sass-loader?sourceMap'
})
}
]
},
Expand All @@ -69,11 +76,14 @@ var config = {
modules: false,
assets: true
}),
new ExtractTextPlugin(production ? '[name]-[chunkhash].css' : '[name].css', {
allChunks: true
new ExtractTextPlugin({
filename: production ? '[name]-[chunkhash].css' : '[name].css',
allChunks: true
}),
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(production ? 'production' : 'development') }
'process.env': {
NODE_ENV: JSON.stringify(production ? 'production' : 'development')
}
})
]
};
Expand All @@ -85,7 +95,6 @@ if (production) {
compressor: { warnings: false },
sourceMap: false
}),

new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new CompressionPlugin()
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"eslint": "^3.3.1",
"eslint-plugin-react": "^6.1.2",
"expose-loader": "~0.6.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"identity-obj-proxy": "^3.0.0",
"jest-cli": "^16.0.1",
Expand All @@ -36,7 +35,7 @@
"stats-webpack-plugin": "^0.2.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.9.11",
"webpack": "^2.5.1",
"webpack-dev-server": "^1.9.0"
},
"optionalDependencies": {
Expand All @@ -48,6 +47,7 @@
"datatables.net": "~1.10.12",
"datatables.net-bs": "~1.10.12",
"diff": "~3.0.0",
"extract-text-webpack-plugin": "^2.1.0",
"ipaddr.js": "~1.2.0",
"jquery": "~2.2.4",
"jquery-flot": "~0.8.3",
Expand All @@ -56,6 +56,7 @@
"jstz": "~1.0.7",
"lodash": "~4.15.0",
"multiselect": "~0.9.12",
"fbjs": "0.8.12",
"react": "^15.1.0",
"react-bootstrap": "^0.30.0",
"react-dom": "^15.1.0",
Expand Down
10 changes: 5 additions & 5 deletions webpack/assets/javascripts/bundle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require('expose?$!expose?jQuery!jquery');
require('expose-loader?$!expose-loader?jQuery!jquery');
require('jquery-ujs');
require('expose?_!lodash');
require('expose?jstz!jstz');
require('expose?ipaddr!ipaddr.js');
require('expose-loader?_!lodash');
require('expose-loader?jstz!jstz');
require('expose-loader?ipaddr!ipaddr.js');
require('jquery.cookie');
require('expose?JsDiff!diff');
require('expose-loader?JsDiff!diff');
require('./bundle_flot');
require('./bundle_multiselect');
require('./bundle_select2');
Expand Down

0 comments on commit eb7c1ef

Please sign in to comment.