2 Star 0 Fork 0

烤鸭的世界我们不懂/7zhanglao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 3.62 KB
一键复制 编辑 原始数据 按行查看 历史
烤鸭的世界我们不懂 提交于 2019-07-13 08:46 . 更改首页图片
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');
const HtmlWebpackPlugin = require('html-webpack-plugin'); // 通过 npm 安装
const Visualizer = require('webpack-visualizer-plugin'); // remove it in production environment.
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // remove it in production environment.
const otherPlugins = process.argv[1].indexOf('webpack-dev-server') >= 0 ? [] : [
new Visualizer(), // remove it in production environment.
new BundleAnalyzerPlugin({
defaultSizes: 'parsed',
// generateStatsFile: true,
statsOptions: { source: false }
}), // remove it in production environment.
];
const postcssOpts = {
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
plugins: () => [
autoprefixer({
browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 8', 'iOS >= 8', 'Android >= 4'],
}),
// pxtorem({ rootValue: 100, propWhiteList: [] })
],
};
module.exports = {
devtool: 'source-map', // or 'inline-source-map'
devServer: {
disableHostCheck: true,
host: '0.0.0.0',
proxy: {
'/app/**': {
contentBase: path.join(__dirname, '.'),
target: "http://app.7zhanglao.vip/app/",
// target: "http://localhost:8762/app/",
changeOrigin:true,
pathRewrite: {'^/app': ''},
}
}
},
entry: { "index": path.resolve(__dirname, 'src/index.js') },
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.join(__dirname, 'dist'),
publicPath: './'
},
resolve: {
modules: [path.resolve(__dirname, 'node_modules'), path.join(__dirname, 'src')],
extensions: ['.web.js', '.jsx', '.js', '.json'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader',
options: {
plugins: [
'external-helpers', // why not work?
["transform-runtime", { polyfill: false }],
["import", [{ "style": "css", "libraryName": "antd-mobile" }]]
],
presets: ['es2015', 'stage-0', 'react']
// presets: [['es2015', { modules: false }], 'stage-0', 'react'] // tree-shaking
}
},
{ test: /\.(jpg|png)$/, loader: "url-loader?limit=8192" },
// 注意:如下不使用 ExtractTextPlugin 的写法,不能单独 build 出 css 文件
// { test: /\.less$/i, loaders: ['style-loader', 'css-loader', 'less-loader'] },
// { test: /\.css$/i, loaders: ['style-loader', 'css-loader'] },
{
test: /\.less$/i, use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader', { loader: 'postcss-loader', options: postcssOpts }, 'less-loader'
]
})
},
{
test: /\.css$/i, use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader', { loader: 'postcss-loader', options: postcssOpts }
]
})
}
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM"
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
// new webpack.optimize.CommonsChunkPlugin('shared.js'),
new webpack.optimize.CommonsChunkPlugin({
// minChunks: 2,
name: 'shared',
filename: 'shared.js'
}),
new HtmlWebpackPlugin({template: './index.html'}),
new ExtractTextPlugin({ filename: '[name].css', allChunks: true }),
...otherPlugins
]
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fireduck_admin/7zhanglao.git
[email protected]:fireduck_admin/7zhanglao.git
fireduck_admin
7zhanglao
7zhanglao
master

搜索帮助