Authored by 陈峰

commit

{
"presets": [
"es2015",
"react",
"stage-0"
],
"plugins": [
"react-loadable/babel",
"transform-runtime",
"syntax-dynamic-import"
]
}
\ No newline at end of file
... ... @@ -5,4 +5,5 @@ let conf = params => httpService.postJson(config.domain + '/api/activity/wheelSu
let start = params => httpService.postJson(config.domain + '/api/activity/wheelSurf/start', params);
let prize = params => httpService.postJson(config.domain + '/api/activity/wheelSurf/user/prize', params);
let resource = query => httpService.get(config.domain + '/api/common/resource', query);
module.exports = {conf, start, prize, resource};
\ No newline at end of file
export default {conf, start, prize, resource};
\ No newline at end of file
... ...
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/promise'
import 'core-js/es6/object'
import 'whatwg-fetch'
import React from 'react';
import {render} from 'react-dom';
import config from '../../config';
import {BrowserRouter, Route, Switch, HashRouter, hashHistory, browserHistory} from 'react-router-dom';
import {BrowserRouter, Route, Switch} from 'react-router-dom';
import router from './router';
const router = require('./router');
const routers = () => {
let arr = [];
... ... @@ -24,10 +31,8 @@ const SliderComponent = () => (
</Switch>
);
render(
<BrowserRouter history={browserHistory}>
<Switch>
<BrowserRouter>
<SliderComponent/>
</Switch>
</BrowserRouter>,
document.querySelector("#root")
);
\ No newline at end of file
... ...
... ... @@ -15,7 +15,7 @@ const prize = Loadable({
},
});
module.exports = {
export default {
home,
prize
};
... ...
import React from 'react';
import {resource} from '../../../api';
import api from '../../../api';
import {image} from '../../../../../common/utils';
import yaSDK from 'yoho-activity-sdk';
... ... @@ -17,7 +17,7 @@ export default class Resource extends React.Component {
loadResource = async () => {
try {
let result = await resource({contentCode: this.props.code});
let result = await api.resource({contentCode: this.props.code});
if (result.code === 200) {
this.setState({
... ...
import React, {PureComponent} from 'react';
import './index.scss'
import {conf, start} from '../../api'
import api from '../../api'
import yaSDK from 'yoho-activity-sdk';
import config from '../../../../config';
import cookie from 'react-cookies';
import LazyLoad from 'react-lazy-load'
import {
Link
} from 'react-router-dom'
import Resource from '../components/resource';
import BottomButton from '../components/bottom-button';
... ... @@ -103,7 +99,7 @@ export default class wheelSurf extends PureComponent {
params.uid = this.state.uid;
}
let result = await conf(params);
let result = await api.conf(params);
if (result.code === 200) {
this.setState({
... ...
import React, {PureComponent} from 'react';
import './index.scss'
import {prize} from '../../api';
import api from '../../api';
import yaSDK from 'yoho-activity-sdk';
import config from '../../../../config';
import wx from 'weixin-js-sdk';
import TipModal from '../components/tip-modal';
import moment from 'moment';
import dayjs from 'dayjs';
export default class Prize extends PureComponent {
constructor(props) {
... ... @@ -53,7 +52,7 @@ export default class Prize extends PureComponent {
componentDidMount() {
yaSDK.getUid().then(async uid => {
let result = await prize({
let result = await api.prize({
act_id: +yaSDK.getQueryObj().actId,
uid: uid || +yaSDK.getQueryObj().uid
});
... ... @@ -73,7 +72,7 @@ export default class Prize extends PureComponent {
let redEnvelopeLink = 'https://activity.yoho.cn/feature/3221.html?title=我的红包&openby:yohobuy={"action":"go.mineredpackage"}';
this.state.prizes.map(prize => {
prize.createTime = moment(new Date(prize.createTime).getTime()).format('YYYY-MM-DD HH:mm');
prize.createTime = dayjs(new Date(prize.createTime).getTime()).format('YYYY-MM-DD HH:mm');
});
return (
... ...
module.exports = {
"presets": [
["@babel/preset-env", {
"modules": false,
"useBuiltIns": 'usage'
}],
"@babel/preset-react"
],
"plugins": [
["@babel/syntax-dynamic-import"],
["@babel/transform-react-constant-elements"],
["@babel/proposal-class-properties"]
]
}
... ...
import {stringify} from 'query-string';
const {stringify} = require('query-string')
module.exports = {
export default {
postForm: (targetAPIUri, formData) => {
return fetch(targetAPIUri, {
method: 'POST',
... ...
const currentApp = 'wheelSurf';
export default {
module.exports = {
production: {
routerPath: {
wheelSurf: '/html5/2018/10/wheelSurf',
... ...
... ... @@ -8,17 +8,19 @@
"description": "",
"main": "app.js",
"scripts": {
"build": "webpack --mode development --config ./webpack.config.babel.js ",
"start": "webpack-dev-server --mode development --config ./webpack.config.babel.js",
"build-prd": "webpack --mode production --config ./webpack.config.babel.js ",
"start-prd": "webpack-dev-server --mode production --config ./webpack.config.babel.js"
"build": "webpack --mode development --config ./webpack.config.js ",
"start": "webpack-dev-server --mode development --config ./webpack.config.js",
"build-prd": "webpack --mode production --config ./webpack.config.js",
"start-prd": "webpack-dev-server --mode production --config ./webpack.config.js"
},
"dependencies": {
"dateformat": "^3.0.3",
"dayjs": "^1.7.7",
"jquery": "^3.3.1",
"moment": "^2.22.1",
"moment-timezone": "^0.5.15",
"prop-types": "^15.6.1",
"query-string": "5",
"react": "^16.3.2",
"react-cookies": "^0.1.0",
"react-dom": "^16.3.2",
... ... @@ -27,20 +29,23 @@
"react-moment": "^0.7.0",
"react-router-dom": "^4.2.2",
"react-slick": "^0.23.1",
"weixin-js-sdk": "^1.3.3"
"weixin-js-sdk": "^1.3.3",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/plugin-transform-react-constant-elements": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.1.2",
"@babel/runtime-corejs2": "^7.1.2",
"autoprefixer": "^9.1.4",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-import": "^1.7.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-loader": "^8.0.2",
"clean-webpack-plugin": "^0.1.19",
"compression-webpack-plugin": "^1.1.11",
"copy-webpack-plugin": "^4.5.1",
... ... @@ -57,11 +62,12 @@
"postcss-import": "^12.0.0",
"postcss-loader": "^3.0.0",
"postcss-pxtorem": "^4.0.1",
"query-string": "^6.2.0",
"sass-loader": "^7.1.0",
"script-loader": "^0.7.2",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"webpack": "^4.17.2",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.3",
"webpack-merge": "^4.1.4",
... ...
import webpack, {DefinePlugin} from 'webpack';
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
import path from 'path';
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import CleanWebpackPlugin from 'clean-webpack-plugin';
import HtmlWebpackPlugin from "html-webpack-plugin";
import config from "./config";
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const config = require("./config");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const appHtmls = require('./app/' + config.currentApp + '/title');
let pathsToClean = [
'dist'
... ... @@ -15,8 +18,9 @@ let cleanOptions = {
verbose: true,
dry: false
};
let baseArr = [
new DefinePlugin({//全局变量
let plugins = [
new webpack.DefinePlugin({//全局变量
PRODUCTION: false
}),
new MiniCssExtractPlugin({
... ... @@ -26,28 +30,15 @@ let baseArr = [
chunkFilename: "css/[id].css"
}),//css分离
new CleanWebpackPlugin(pathsToClean, cleanOptions),//清除历史版本
new UglifyJsPlugin({test: /\.js($|\?)/i,parallel: false})
];
let htmls = function () {
const title = require('./app/' + config.currentApp + '/title');
let arr = [];
for (let i in title) {
arr.push(new HtmlWebpackPlugin({
filename: i + '.html',
new BundleAnalyzerPlugin()
].concat(Object.keys(appHtmls).map(title => {
return new HtmlWebpackPlugin({
filename: title + '.html',
template: './index.ejs',
title: title[i],
title,
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
}
}))
}
arr = arr.concat(baseArr);
return arr
};
})
}));
module.exports = {
optimization: {
... ... @@ -58,7 +49,20 @@ module.exports = {
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
]
],
splitChunks: {
chunks () {
return false
},
cacheGroups: {
default: false,
vendors: {
chunks: 'all',
name: 'vendors',
test: /node_modules/,
}
}
}
},
//项目入口js文件
entry: [`./app/${config.currentApp}/index.js`],
... ... @@ -69,18 +73,16 @@ module.exports = {
filename: '[name].[chunkhash:8].js',
},
//插件
plugins: htmls(),
plugins,
//加载器
module: {
rules: [
{
test: /\.js/,
exclude: /node_modules/,
use: [
{
use: [{
loader: 'babel-loader',
}
]
}]
},
{
test: /\.(sa|sc|c)ss$/,
... ... @@ -95,7 +97,7 @@ module.exports = {
test: /\.(png|jpg|gif)$/,
use: "url-loader?limit=8192",
},
{test: /\.html$/, use: 'html-withimg-loader'},
// {test: /\.html$/, use: 'html-withimg-loader'},
{test: /\.json$/, use: 'json-loader'}
]
},
... ...
This diff could not be displayed because it is too large.