Skip to content

Commit

Permalink
fix: #20
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoidjk committed Jul 13, 2017
1 parent 776cd0c commit e967f0d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
9 changes: 9 additions & 0 deletions create-react-app/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ module.exports = {
/\.gif$/,
/\.jpe?g$/,
/\.png$/,
/\.svg$/,
],
loader: require.resolve('file-loader'),
options: {
Expand Down Expand Up @@ -210,6 +211,14 @@ module.exports = {
},
},
],
},
{
test: /\.(svg)$/i,
loader: 'svg-sprite-loader',
include: [
require.resolve('antd-mobile').replace(/warn\.js$/, ''), // 1. svg files of antd-mobile
path.resolve(__dirname, '../src/'), // folder of svg files in your project
]
},
// Parse less files and modify variables
{
Expand Down
49 changes: 45 additions & 4 deletions create-react-app/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pxtorem = require('postcss-pxtorem');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
Expand Down Expand Up @@ -82,9 +83,9 @@ module.exports = {
// We also include JSX as a common component filename extension to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx'],
extensions: ['.web.js', '.js', '.json', '.jsx'],
alias: {

// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
Expand Down Expand Up @@ -114,7 +115,7 @@ module.exports = {
{
options: {
formatter: eslintFormatter,

},
loader: require.resolve('eslint-loader'),
},
Expand All @@ -139,6 +140,8 @@ module.exports = {
/\.gif$/,
/\.jpe?g$/,
/\.png$/,
/\.less$/,
/\.svg$/,
],
loader: require.resolve('file-loader'),
options: {
Expand All @@ -160,7 +163,12 @@ module.exports = {
test: /\.(js|jsx)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),

options: {
plugins: [
['import', { libraryName: 'antd-mobile', style: true }],
],
cacheDirectory: true,
}
},
// The notation here is somewhat confusing.
// "postcss" loader applies autoprefixer to our CSS.
Expand Down Expand Up @@ -216,6 +224,39 @@ module.exports = {
},
// ** STOP ** Are you adding a new loader?
// Remember to add the new extension(s) to the "file" loader exclusion list.
{
test: /\.(svg)$/i,
loader: 'svg-sprite-loader',
include: [
require.resolve('antd-mobile').replace(/warn\.js$/, ''), // 1. svg files of antd-mobile
path.resolve(__dirname, '../src/'), // folder of svg files in your project
]
},
{
test: /\.less$/,
use: [
require.resolve('style-loader'),
require.resolve('css-loader'),
{
loader: require.resolve('postcss-loader'),
options: {
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: [] })
],
},
},
{
loader: require.resolve('less-loader'),
options: {
modifyVars: { "@primary-color": "#1DA57A" },
},
},
],
},
],
},
plugins: [
Expand Down
1 change: 1 addition & 0 deletions create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-dev-utils": "^3.0.0",
"react-error-overlay": "^1.0.7",
"style-loader": "0.17.0",
"svg-sprite-loader": "^0.3.1",
"sw-precache-webpack-plugin": "0.9.1",
"url-loader": "0.5.8",
"webpack": "2.6.1",
Expand Down
6 changes: 3 additions & 3 deletions create-react-app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Button } from 'antd-mobile';
import { Button, Icon } from 'antd-mobile';
import logo from './logo.svg';
import './App.css';

Expand All @@ -8,13 +8,13 @@ class App extends Component {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<Icon type={logo} className="App-logo" size="lg"/>
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<Button>This is a button</Button>
<Button type="primary">This is a button</Button>
</div>
);
}
Expand Down

1 comment on commit e967f0d

@paranoidjk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #14

Please sign in to comment.