feat: use less

This commit is contained in:
sean 2017-08-22 10:43:40 +08:00
parent 37e4d469f8
commit a695302118
4 changed files with 34 additions and 19 deletions

View File

@ -4,6 +4,7 @@ import App from './Application'
import { Provider } from 'react-redux'
import createStore from './reducer/create';
import { DevTools } from './containers';
import './styles/theme.less'
const store = createStore();

4
client/styles/theme.less Normal file
View File

@ -0,0 +1,4 @@
@import '~antd/dist/antd.less';
@primary-color : blue;

View File

@ -65,6 +65,8 @@
"koa-static": "^3.0.0",
"koa-views": "^5.2.0",
"koa-websocket": "^4.0.0",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"mock": "^0.1.1",
"mockjs": "^1.0.1-beta3",
"moment": "^2.18.1",

46
ykit.js
View File

@ -9,22 +9,22 @@ var assetsPluginInstance = new AssetsPlugin({
function handleCommonsChunk(webpackConfig) {
var commonsChunk = {
//filename: 'scripts/[name]@[chunkhash][ext]',
vendors: {
lib: ['react', 'redux',
'redux-thunk',
'react-dom',
'redux-promise',
'react-router-dom',
'prop-types'
//filename: 'scripts/[name]@[chunkhash][ext]',
vendors: {
lib: ['react', 'redux',
'redux-thunk',
'react-dom',
'redux-promise',
'react-router-dom',
'prop-types'
],
lib2: [
'axios',
'moment'
]
}
},
],
lib2: [
'axios',
'moment'
]
}
},
chunks = [],
filenameTpl = webpackConfig.output[this.env],
vendors;
@ -78,7 +78,7 @@ module.exports = {
"regenerator": true
}]);
defaultQuery.plugins.push('transform-decorators-legacy');
defaultQuery.plugins.push(["import", { libraryName: "antd", style: "css" }])
// defaultQuery.plugins.push(["import", { libraryName: "antd", style: "css" }])
return defaultQuery;
}
}
@ -102,8 +102,8 @@ module.exports = {
ENV_PARAMS = { development: false };
break;
default:
}
}
baseConfig.plugins.push(new this.webpack.DefinePlugin({
ENV_PARAMS: JSON.stringify(ENV_PARAMS)
}))
@ -117,7 +117,15 @@ module.exports = {
//commonsChunk
handleCommonsChunk.call(this, baseConfig)
baseConfig.module.loaders.push({
test: /\.less$/,
loader: ykit.ExtractTextPlugin.extract(
require.resolve('style-loader'),
require.resolve('css-loader')
+ '?sourceMap!'
+ require.resolve('less-loader') + '?sourceMap'
)
})
baseConfig.module.loaders.push({
test: /\.(sass|scss)$/,
loader: ykit.ExtractTextPlugin.extract(