Webpack配置
Posted 千年易小川
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Webpack配置相关的知识,希望对你有一定的参考价值。
const path = require(‘path‘); const Webpack = require(‘webpack‘); const htmlWebpackPlugin = require(‘html-webpack-plugin‘); const ManifestPlugin = require(‘webpack-manifest-plugin‘); const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin‘); module.exports = { entry: path.resolve(__dirname, ‘../src/index.jsx‘), output: { filename: "[name].bundle.js", path: path.resolve(__dirname, ‘dist‘), publicPath: process.env === ‘production‘ ? ‘dist‘ : ‘/‘ }, devtool: ‘inline-source-map‘, devServer: { contentBase: ‘./dist‘, hot: true, inline: true, open: true, overlay: true, host: ‘0.0.0.0‘, proxy: {} }, resolve: { extensions: [‘.less‘, ‘.jsx‘, ‘.js‘], alias: { ‘@‘: ‘src‘, ‘components‘: ‘src/components‘, ‘container‘: ‘src/container‘, ‘view‘: ‘src/view‘, ‘common‘: ‘src/common‘, ‘base‘: ‘src/base‘ } }, module: { rules: [ { test: ‘/.css$/‘, use: [‘css-loader‘, ‘style-loader‘] }, { test: ‘/.jsx/‘, use: [‘babel-loader‘] }, { test: ‘/.(png|jpg|svg|gif|woff|woff2|eot|ttf|otf)$/‘, use: [‘file-loader‘] } ] }, plugins: [ new ManifestPlugin(), new HtmlWebpackPlugin({ title: "Webpack App" }), new UglifyJsPlugin({ sourceMap: true }), new Webpack.optimize.CommonsChunkPlugin({ name: ‘manifest‘ }), new Webpack.HotModuleReplacementPlugin(), new Webpack.DefinePlugin({ ‘process.env.NODE_ENV‘: JSON.stringify(‘production‘) }), ] };
以上是关于Webpack配置的主要内容,如果未能解决你的问题,请参考以下文章
Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法(代码片段