Skip to content

Commit 28af80f

Browse files
committed
解决打成包的时候,basename问题
1 parent 6075413 commit 28af80f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/containers/Counter/Counter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44
import * as cActions from 'reducers/counter';
5-
import { Utility, Navbar } from 'components';
5+
import { Utility } from 'components';
66
const comStyles = require('styles/Common.scss');
77

88
@connect((state) => ({ counter: state.counter }), { ...cActions })
@@ -22,7 +22,6 @@ export default class Counter extends Component {
2222
const { increment, decrement, reset } = this.props;
2323
return (
2424
<div>
25-
<Navbar Title="Counter" />
2625
<div className={comStyles.btns}>
2726
<button onClick={() => Utility.toPage('userinfo')}>go to userinfo</button>
2827
<button onClick={() => Utility.$goBack()}>go back</button>

src/router/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const getTransitionsName = (isReturn, styles) => {
4747
const __timeout = 500;
4848

4949
const getRouters = () => (
50-
<Router basename="/react">
50+
<Router basename="/react/">
5151
<div className={routerCss.appContent}>
5252
<Route path="/" component={CreateComponent(Home)} />
5353
<Route render={({ location }) => (

webpack.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const merge = require('webpack-merge');
1111
const CommCfg = require('./wepback.common.config.js');
1212

1313
const proCfg = {
14-
devtool: 'cheap-module-source-map',
14+
// devtool: 'cheap-module-source-map',
15+
devtool: 'source-map',
1516
module: {
1617
rules: [
1718
{ test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) },
@@ -44,12 +45,12 @@ const proCfg = {
4445
]
4546
},
4647
plugins: [
47-
new CleanWebpackPlugin(['dist/www']),
48+
new CleanWebpackPlugin(['dist/react']),
4849
new UglifyJSPlugin(),
49-
new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') } }),
50+
new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }),
5051
new ExtractTextPlugin({ filename: '[name].[contenthash:5].css', allChunks: true }),
5152
],
52-
}
53+
};
5354

5455
module.exports = merge(CommCfg, proCfg);
5556

wepback.common.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const Config = {
88
vendor: ['react', 'react-router-dom', 'redux', 'react-dom', 'react-redux']
99
},
1010
output: {
11-
path: path.join(__dirname, './dist/www'),
11+
path: path.join(__dirname, './dist/react'),
1212
filename: '[name].[chunkhash].js',
1313
chunkFilename: '[name].[chunkhash].js',
14-
publicPath: '/'
14+
publicPath: '/react/' // 这里必须和router里面写的那个basename要一样。要不能会出问题。
1515
},
1616
module: {
1717
rules: [

0 commit comments

Comments
 (0)