1 Star 0 Fork 0

tsword/react-page-ie8

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.dev.js 4.30 KB
一键复制 编辑 原始数据 按行查看 历史
EvanYao 提交于 2018-04-28 17:05 . surport mutilple
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;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tsword/react-page-ie8.git
git@gitee.com:tsword/react-page-ie8.git
tsword
react-page-ie8
react-page-ie8
master

搜索帮助