Created
June 19, 2017 23:34
-
-
Save sdtsui/3fe95e0fbd0af28c586e257ad470f449 to your computer and use it in GitHub Desktop.
webpack-moduleconcatentationplugin-issue-config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We merge our configs. Here are all of the files used. | |
// webpack.frontend.prod.js | |
const webpack = require('webpack'); | |
const merge = require('webpack-merge'); | |
const CompressionPlugin = require('compression-webpack-plugin'); | |
const baseFrontendConfig = require('./webpack.frontend.base'); | |
module.exports = merge.smart(baseFrontendConfig, { | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('production'), | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
sourceMap: true, | |
beautify: false, | |
mangle: { | |
screw_ie8: true, | |
keep_fnames: true, | |
}, | |
compress: { | |
screw_ie8: true, | |
}, | |
comments: false, | |
}), | |
new CompressionPlugin({ | |
asset: '[path].gz[query]', | |
algorithm: 'gzip', | |
test: /\.js$|\.html$|\.scss$|\.jsx$|/, | |
threshold: 10240, | |
minRatio: 0.8, | |
}), | |
new webpack.optimize.ModuleConcatenationPlugin(), | |
], | |
}); | |
// webpack.frontend.base.js | |
const path = require('path'); | |
const merge = require('webpack-merge'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const baseConfig = require('./webpack.base'); | |
const root = process.cwd(); | |
module.exports = merge.smart(baseConfig, { | |
module: { | |
noParse: [/node_modules\/flexibility\/flexibility.js/], | |
}, | |
entry: [ | |
/* scripts */ | |
'babel-polyfill', | |
'isomorphic-fetch', | |
'./frontend/src/index', | |
/* styles */ | |
'bootstrap/dist/css/bootstrap.css', | |
], | |
output: { | |
path: path.join(root, 'frontend/dist'), | |
publicPath: '/', | |
filename: 'scripts.bundle.js', | |
}, | |
plugins: [ | |
new ExtractTextPlugin({ | |
filename: 'styles.bundle.css', | |
}), | |
new CopyWebpackPlugin([{ | |
context: path.resolve(process.cwd(), 'node_modules', 'flexibility'), | |
from: 'flexibility.js', | |
}]), | |
], | |
}); | |
// webpack.base.js | |
const path = require('path'); | |
const Dotenv = require('dotenv-webpack'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const webpack = require('webpack'); | |
const root = process.cwd(); | |
module.exports = { | |
module: { | |
rules: [ | |
{ | |
test: /\.jsx?$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
}, | |
{ | |
test: /\.woff|\.woff2|\.svg|.eot|\.ttf/, | |
use: [ | |
{ | |
loader: 'url-loader', | |
options: { | |
prefix: 'font/', | |
limit: 10000, | |
}, | |
}, | |
], | |
}, | |
{ | |
test: /\.css$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: 'css-loader', | |
}), | |
}, | |
{ | |
test: /\.scss$/, | |
use: [ | |
'style-loader', | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
camelCase: true, | |
importLoaders: 1, | |
localIdentName: '[name]__[local]___[hash:base64:5]', | |
}, | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
config: { | |
path: path.join(root, 'configuration', 'postcss.config.js'), | |
}, | |
}, | |
}, | |
'sass-loader', | |
], | |
}, | |
{ | |
test: /\.png/, | |
use: [ | |
{ | |
loader: 'url-loader', | |
options: { | |
limit: 100000, | |
mimetype: 'image/png', | |
}, | |
}, | |
], | |
}, | |
{ | |
test: /\.jpg/, | |
use: 'file-loader', | |
}, | |
], | |
}, | |
resolve: { | |
modules: [ | |
'node_modules', | |
'frontend/src', | |
'shared/src', | |
], | |
alias: { | |
configuration: path.join(root, 'configuration'), | |
api: path.join(root, 'frontend/src/app/domainData/api'), | |
components: path.join(root, 'frontend/src/app/components'), | |
frontend: path.join(root, 'frontend/src'), | |
jsonServer: path.join(root, 'json-server'), | |
scss: path.join(root, 'frontend/src/app/scss'), | |
shared: path.join(root, 'shared/src'), | |
siteCanvas: path.join(root, 'frontend/src/canvas/siteCanvas'), | |
Toolbar: path.join(root, 'frontend/src/canvas/siteCanvas/tools/Toolbar'), | |
FeatureFlag: path.join(root, 'frontend/src/app/FeatureFlag'), | |
Notifications: path.join(root, 'frontend/src/app/Notifications'), | |
}, | |
extensions: ['.js', '.jsx'], | |
}, | |
plugins: [ | |
new Dotenv({ | |
path: path.join(root, '.env.dev'), | |
}) | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment