rj-tool-test
Version:
rj tool
57 lines (52 loc) • 1.73 kB
JavaScript
/**
* Created by feichongzheng on 16/12/7.
*/
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
// const PreloadWebpackPlugin = require('preload-webpack-plugin');
const webpackModule = require('./module');
module.exports = ({rootDir, port = '8000'}) => {
return {
mode: 'development',
entry: ['babel-polyfill', rootDir + '/app/index.js'],
output: {
path: rootDir + '/public',
filename: 'js/[name].[hash:8].bundle.js',
chunkFilename: 'js/[name]-[id].[hash:8].bundle.js',
pathinfo: true
},
module: webpackModule,
plugins: [
new CleanPlugin(['public'], {
'root': rootDir,
'verbose': true,
'dry': false,
}),
new CopyWebpackPlugin([
{from: rootDir + '/assets', to: rootDir + '/public/assets'},
]),
new HtmlWebpackPlugin({
template: rootDir + '/app/index.html',
}),
// new PreloadWebpackPlugin({
// rel: 'preload',
// include: ['Uc','App']
// }),
new webpack.HotModuleReplacementPlugin(),
],
devtool: 'source-map',
devServer: {
contentBase: path.join(rootDir, 'public'),
compress: false,
host: "0.0.0.0",
port: port,
historyApiFallback: true,
inline: true,
hot: true,
hotOnly: true,
},
};
};