Commit a1c1c8b0 by 小明

加入构建时 assets 资源复制及 http 请求 svg 资源的响应

parent 1b0e0abf
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = (options) => ({ module.exports = (options) => ({
...@@ -91,6 +92,18 @@ module.exports = (options) => ({ ...@@ -91,6 +92,18 @@ module.exports = (options) => ({
allChunks: true, allChunks: true,
}), }),
/*
* Plugin: CopyWebpackPlugin
* Description: Copy files and directories in webpack.
*
* Copies project static assets.
*
* See: https://www.npmjs.com/package/copy-webpack-plugin
*/
new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' },
]),
new webpack.NamedModulesPlugin(), new webpack.NamedModulesPlugin(),
]), ]),
resolve: { resolve: {
......
...@@ -119,6 +119,7 @@ ...@@ -119,6 +119,7 @@
"chai": "3.5.0", "chai": "3.5.0",
"chai-enzyme": "0.5.2", "chai-enzyme": "0.5.2",
"cheerio": "0.22.0", "cheerio": "0.22.0",
"copy-webpack-plugin": "^4.0.1",
"coveralls": "2.11.14", "coveralls": "2.11.14",
"css-loader": "0.25.0", "css-loader": "0.25.0",
"enzyme": "2.5.1", "enzyme": "2.5.1",
......
...@@ -16,10 +16,20 @@ const addDevMiddlewares = (app, webpackConfig) => { ...@@ -16,10 +16,20 @@ const addDevMiddlewares = (app, webpackConfig) => {
silent: true, silent: true,
stats: 'errors-only', stats: 'errors-only',
}); });
app.use(middleware); app.use(middleware);
app.use(webpackHotMiddleware(compiler)); app.use(webpackHotMiddleware(compiler));
// 针对开发环境加入svg资源处理
app.use('/assets', (req, res) => {
fs.readFile(path.join('/assets', req.path), (err, file) => {
if (err) {
res.sendStatus(404);
} else {
res.send(file.toString());
}
});
});
// Since webpackDevMiddleware uses memory-fs internally to store build // Since webpackDevMiddleware uses memory-fs internally to store build
// artifacts, we use it instead // artifacts, we use it instead
const fs = middleware.fileSystem; const fs = middleware.fileSystem;
......
...@@ -35,7 +35,16 @@ class DashboardIndex extends PureComponent { // eslint-disable-line react/prefer ...@@ -35,7 +35,16 @@ class DashboardIndex extends PureComponent { // eslint-disable-line react/prefer
loading: true, loading: true,
logined: true, logined: true,
is_admin: false, is_admin: false,
icons: false, icons:{
purchase: 'assets/images/symbols.svg#purchase',
sale: 'assets/images/symbols.svg#sale',
other: 'assets/images/symbols.svg#other',
document: 'assets/images/symbols.svg#document',
inventory: 'assets/images/symbols.svg#inventory',
customer: 'assets/images/symbols.svg#customer',
supplier: 'assets/images/symbols.svg#supplier',
product: 'assets/images/symbols.svg#purchase'
},
new_buttons: [], new_buttons: [],
purchase_buttons: [], purchase_buttons: [],
sale_buttons: [], sale_buttons: [],
......
...@@ -90,7 +90,6 @@ class DashboardIndexMember extends Component { // eslint-disable-line react/pref ...@@ -90,7 +90,6 @@ class DashboardIndexMember extends Component { // eslint-disable-line react/pref
if (shortcut.onClick) { if (shortcut.onClick) {
href = 'javascript:void(0);'; href = 'javascript:void(0);';
} }
fragments.push(<Col span="6" className={className} key={shortcut.type}> fragments.push(<Col span="6" className={className} key={shortcut.type}>
<a className="shortcut-link" href={href} onClick={shortcut.onClick}> <a className="shortcut-link" href={href} onClick={shortcut.onClick}>
<svg> <svg>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment