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 Jun 4, 2017
1 parent 3501ac9 commit 7dd7ad7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
35 changes: 21 additions & 14 deletions config/webpack.config.js
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,8 +76,9 @@ 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': {
Expand All @@ -88,7 +96,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
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 @@ -37,7 +36,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 @@ -49,6 +48,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 @@ -58,6 +58,7 @@
"lodash": "~4.15.0",
"multiselect": "~0.9.12",
"prop-types": "^15.5.9",
"fbjs": "0.8.12",
"react": "^15.1.0",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.1.0",
Expand Down
10 changes: 5 additions & 5 deletions webpack/assets/javascripts/bundle.js
@@ -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 7dd7ad7

Please sign in to comment.