mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-28 04:05:21 +08:00
73 lines
2.0 KiB
JavaScript
73 lines
2.0 KiB
JavaScript
const webpack = require('webpack');
|
|
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
|
|
let config = {
|
|
entry: {
|
|
polyfill: 'babel-polyfill',
|
|
app: path.join(__dirname, 'client', 'index.js')
|
|
},
|
|
output: {
|
|
path: path.join(__dirname, 'server', 'public'),
|
|
publicPath: '/',
|
|
filename: 'js/[name].js',
|
|
chunkFilename: "js/chunk.[name].[id].js"
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: path.join(__dirname, 'client'),
|
|
use: ['babel-loader'],
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.html$/,
|
|
loader: 'html-loader'
|
|
},
|
|
{
|
|
test: /\.scss$/,
|
|
loaders: ['style-loader', 'css-loader', 'sass-loader']
|
|
},
|
|
{
|
|
test: /\.(pdf|jpg|png|gif|svg|ico)$/,
|
|
loader: "url-loader?mimetype=image/png"
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.DefinePlugin({
|
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
}),
|
|
new webpack.optimize.OccurrenceOrderPlugin(),
|
|
new HtmlWebpackPlugin({
|
|
template: path.join(__dirname, 'client', 'index.html'),
|
|
inject:true
|
|
}),
|
|
new webpack.optimize.CommonsChunkPlugin({name: "polyfill", filename: "js/polyfill.js"}),
|
|
]
|
|
};
|
|
|
|
|
|
|
|
if(process.env.NODE_ENV === 'production'){
|
|
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
|
|
}else{
|
|
config.devtool = '#inline-source-map';
|
|
config.devServer = {
|
|
contentBase: path.join(__dirname, "server", "public"),
|
|
disableHostCheck: true,
|
|
hot: true,
|
|
historyApiFallback: {
|
|
index: 'index.html'
|
|
},
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:3000'
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = config;
|