mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 15:45:44 +08:00
80 lines
1.5 KiB
JavaScript
80 lines
1.5 KiB
JavaScript
import webpack from 'webpack';
|
|
import ExtractTextPlugin from 'extract-text-webpack-plugin';
|
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
import autoprefixer from 'autoprefixer';
|
|
|
|
var path = require('path');
|
|
|
|
const ENV = process.env.NODE_ENV || 'development';
|
|
|
|
const CSS_MAPS = ENV!=='production';
|
|
|
|
module.exports = {
|
|
context: path.resolve(__dirname, '/src'),
|
|
entry: ['./server'],
|
|
|
|
output: {
|
|
path: `${__dirname}/build`,
|
|
publicPath: '/',
|
|
filename: 'bundle.js',
|
|
library: 'Ask'
|
|
},
|
|
|
|
externals: {},
|
|
|
|
module: {
|
|
preLoaders: [
|
|
{
|
|
test: /\.jsx?$/,
|
|
exclude: /src\//,
|
|
loader: 'source-map'
|
|
}
|
|
],
|
|
loaders: [
|
|
{
|
|
test: /\.jsx?$/,
|
|
exclude: /node_modules/,
|
|
loader: 'babel'
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
loader: 'style-loader!css-loader'
|
|
},
|
|
{
|
|
test: /\.json$/,
|
|
loader: 'json'
|
|
},
|
|
{
|
|
test: /\.(xml|html|txt|md)$/,
|
|
loader: 'raw'
|
|
},
|
|
{
|
|
test: /\.(svg|woff2?|ttf|eot|jpe?g|png|gif)(\?.*)?$/i,
|
|
loader: ENV==='production' ? 'file?name=[path][name]_[hash:base64:5].[ext]' : 'url'
|
|
}
|
|
]
|
|
},
|
|
|
|
plugins: ([
|
|
new webpack.NoErrorsPlugin(),
|
|
new webpack.DefinePlugin({
|
|
'process.env': JSON.stringify({ NODE_ENV: ENV })
|
|
})
|
|
]).concat(ENV==='production' ? [
|
|
new webpack.optimize.OccurenceOrderPlugin()
|
|
] : []),
|
|
|
|
stats: { colors: true },
|
|
|
|
node: {
|
|
global: true,
|
|
process: false,
|
|
Buffer: false,
|
|
__filename: false,
|
|
__dirname: false,
|
|
setImmediate: false
|
|
},
|
|
|
|
devtool: ENV==='production' ? 'source-map' : 'cheap-module-eval-source-map'
|
|
};
|