Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
waliang.wang 2017-07-25 15:11:48 +08:00
commit 4a2ba64bf9
3 changed files with 32 additions and 47 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

75
ykit.js
View File

@ -1,12 +1,10 @@
var path = require('path');
var StringReplacePlugin = require("string-replace-webpack-plugin");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var AssetsPlugin = require('assets-webpack-plugin')
var assetsPluginInstance = new AssetsPlugin({
filename: 'static/prd/assets.js',
processOutput: function (assets) {
return 'window.WEBPACK_ASSETS = ' + JSON.stringify(assets);
}
filename: 'static/prd/assets.js',
processOutput: function (assets) {
return 'window.WEBPACK_ASSETS = ' + JSON.stringify(assets);
}
})
module.exports = {
plugins: [{
@ -19,51 +17,38 @@ module.exports = {
}
}],
// devtool: 'cheap-source-map',
config: function(ykit){
config: function (ykit) {
return {
exports: [
'./index.js'
],
modifyWebpackConfig: function (baseConfig) {
baseConfig.devtool = 'cheap-module-eval-source-map'
baseConfig.context = path.resolve(__dirname, "client");
exports: [
'./index.js'
],
modifyWebpackConfig: function (baseConfig) {
baseConfig.output.prd.path = 'static/prd';
baseConfig.output.prd.publicPath = '';
baseConfig.output.prd.filename = '[name][ext]'
baseConfig.devtool = 'cheap-module-eval-source-map'
baseConfig.context = path.resolve(__dirname, "client");
var stringReplace = {
test: "/static/index.html$",
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /@@VERSION_NUM/,
replacement: function () {
return 11111
}
}
]
baseConfig.output.prd.path = 'static/prd';
baseConfig.output.prd.publicPath = '';
baseConfig.output.prd.filename = '[name][ext]'
baseConfig.plugins.push(assetsPluginInstance)
baseConfig.module.loaders.push({
test: /\.(sass|scss)$/,
loader: ykit.ExtractTextPlugin.extract(
require.resolve('css-loader')
+ '?sourceMap!'
+ require.resolve('fast-sass-loader') + '?sourceMap'
)
})
baseConfig.module.preLoaders.push({
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "eslint-loader"
});
return baseConfig;
}
baseConfig.module.loaders.push(stringReplace)
baseConfig.plugins.push(new StringReplacePlugin())
baseConfig.plugins.push(assetsPluginInstance)
baseConfig.module.loaders.push({
test: /\.(sass|scss)$/,
loader: ykit.ExtractTextPlugin.extract(
require.resolve('css-loader')
+ '?sourceMap!'
+ require.resolve('fast-sass-loader') + '?sourceMap'
)
})
return baseConfig;
}
}
},
server: {
// true/false默认 false效果相当于 ykit server --hot