代码拉取完成,页面将自动刷新
const path = require('path');
const fs = require('fs');
const glob =require('glob');
const webpack = require('webpack');
const AssetsPlugin = require('assets-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const Es3ifyPlugin = require('es3ify-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const helper = require('./webpack.config.helper');
const config = {
disableHostCheck: true,
entry: {
index: './src/index.js',
vendor: ['es5-shim', 'es5-shim/es5-sham', 'es6-promise', 'fetch-ie8', 'console-polyfill'],
},
output: {
path: path.join(__dirname, 'dist'),
chunkFilename: '[name].chunk.js',
filename: '[name].bundle.js',
publicPath: '/',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['vendor', 'manifest'],
// filename: '[name].[chunkhash:8].js'
filename: '[name].js',
}),
new webpack.NoErrorsPlugin(),
new Es3ifyPlugin(),
// 定义全局环境变量为开发环境
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development'),
},
}),
// new webpack.ProvidePlugin({
// $: 'jquery',
// jQuery: 'jquery',
// }),
new AssetsPlugin({
filename: 'dist/webpack-assets.js',
processOutput(assets) {
if (!fs.existsSync('dist')) {
fs.mkdirSync('dist');
}
return `window.WEBPACK_ASSETS = ${JSON.stringify(assets)}`;
},
}),
new ExtractTextPlugin('style.all.css'),
// new HtmlWebpackPlugin({
// filename: 'index.html',
// template: path.resolve(__dirname, 'src/index.ejs'),
// chunks: ['manifest', 'vendor', 'index'],
// }),
],
resolve: {
// 实际就是自动添加后缀,默认是当成js文件来查找路径
// 空字符串在此是为了resolve一些在import文件时不带文件扩展名的表达式
extensions: ['', '.js', 'jsx'],
// 路径别名
alias: {
'~': path.resolve(__dirname, 'src'),
'~home': path.resolve(__dirname, 'src/home'),
'~containers': path.resolve(__dirname, 'src/containers'),
'~components': path.resolve(__dirname, 'src/components'),
'~actions': path.resolve(__dirname, 'src/actions'),
'~api': path.resolve(__dirname, 'src/api'),
'~assets': path.resolve(__dirname, 'src/assets'),
},
},
debug: true,
devtool: 'source-map',
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015-loose','react','stage-2'],
plugins:['babel-plugin-add-module-exports',"babel-plugin-transform-runtime","babel-plugin-transform-regenerator"]
},
},
{
test: /\.(css|less)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?modules&localIdentName=[local]-[hash:base64:5]!less-loader'),
},
{
test: /\.(scss|sass)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?modules&localIdentName=[local]-[hash:base64:5]!sass-loader'),
},
{
test: /(fontawesome-webfont|glyphicons-halflings-regular)\.(woff|woff2|ttf|eot|svg)($|\?)/,
loader: 'url?limit=1024&name=fonts/[name].[hash].[ext]',
},
{
test: /\.(jpg|png)$/,
loader: 'url?limit=100000',
},
{
test: /\.json$/,
loader: 'json',
},
],
postLoaders: [
{
test: /\.js$/,
loaders: ['es3ify-loader'],
},
],
},
devServer: {
// proxy: {
// '/test1': {
// target: 'http://192.168.31.8:9000',
// secure: false,
// },
// },
},
};
helper.extendEntires(config);
helper.extendHtmlPluginList(config);
module.exports=config;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。