Merge pull request #3690 from t3chguy/fix_webpack_config

Fix Webpack conf
This commit is contained in:
Matthew Hodgson 2017-04-22 16:14:19 +01:00 committed by GitHub
commit 634cf528b4

View file

@ -1,7 +1,7 @@
var path = require('path'); const path = require('path');
var webpack = require('webpack'); const webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin"); const ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = { module.exports = {
entry: { entry: {
@ -19,11 +19,11 @@ module.exports = {
// CSS themes // CSS themes
"theme-light": "./src/skins/vector/css/themes/light.scss", "theme-light": "./src/skins/vector/css/themes/light.scss",
"theme-dark": "./src/skins/vector/css/themes/dark.scss" "theme-dark": "./src/skins/vector/css/themes/dark.scss",
}, },
module: { module: {
preLoaders: [ preLoaders: [
{ test: /\.js$/, loader: "source-map-loader" } { test: /\.js$/, loader: "source-map-loader" },
], ],
loaders: [ loaders: [
{ test: /\.json$/, loader: "json" }, { test: /\.json$/, loader: "json" },
@ -38,9 +38,7 @@ module.exports = {
// would also drag in the imgs and fonts that our CSS refers to // would also drag in the imgs and fonts that our CSS refers to
// as webpack inputs.) // as webpack inputs.)
// 3. ExtractTextPlugin turns that string into a separate asset. // 3. ExtractTextPlugin turns that string into a separate asset.
loader: ExtractTextPlugin.extract( loader: ExtractTextPlugin.extract("css-raw-loader!postcss-loader?config=postcss.config.js"),
"css-raw-loader!postcss-loader?config=postcss.config.js"
),
}, },
{ {
// this works similarly to the scss case, without postcss. // this works similarly to the scss case, without postcss.
@ -49,15 +47,18 @@ module.exports = {
}, },
], ],
noParse: [ noParse: [
// for cross platform compatibility use [\\\/] as the path separator
// this ensures that the regex trips on both Windows and *nix
// don't parse the languages within highlight.js. They cause stack // don't parse the languages within highlight.js. They cause stack
// overflows (https://github.com/webpack/webpack/issues/1721), and // overflows (https://github.com/webpack/webpack/issues/1721), and
// there is no need for webpack to parse them - they can just be // there is no need for webpack to parse them - they can just be
// included as-is. // included as-is.
/highlight\.js\/lib\/languages/, /highlight\.js[\\\/]lib[\\\/]languages/,
// olm takes ages for webpack to process, and it's already heavily // olm takes ages for webpack to process, and it's already heavily
// optimised, so there is little to gain by us uglifying it. // optimised, so there is little to gain by us uglifying it.
/olm\/(javascript\/)?olm\.js$/, /olm[\\\/](javascript[\\\/])?olm\.js$/,
], ],
}, },
output: { output: {
@ -83,7 +84,7 @@ module.exports = {
// various levels of '.' and '..' // various levels of '.' and '..'
// Also, sometimes the resource path is absolute. // Also, sometimes the resource path is absolute.
return path.relative(process.cwd(), info.resourcePath).replace(/^[\/\.]*/, ''); return path.relative(process.cwd(), info.resourcePath).replace(/^[\/\.]*/, '');
} },
}, },
resolve: { resolve: {
alias: { alias: {
@ -106,16 +107,13 @@ module.exports = {
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV) NODE_ENV: JSON.stringify(process.env.NODE_ENV),
} },
}), }),
new ExtractTextPlugin( new ExtractTextPlugin("bundles/[hash]/[name].css", {
"bundles/[hash]/[name].css", allChunks: true,
{ }),
allChunks: true
}
),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: './src/vector/index.html', template: './src/vector/index.html',