Skip to content

Commit 5cde1f4

Browse files
committed
把html拿出来单独维护
1 parent 9b2f1fa commit 5cde1f4

8 files changed

+120
-118
lines changed

build/dev-server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const app = express();
1919
const compiler = webpack(webpackConfig);
2020
const devMiddleware = require('webpack-dev-middleware')(compiler, {
2121
publicPath: webpackConfig.output.publicPath,
22-
quiet: true,
22+
quiet: true
2323
});
2424

2525
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
26-
log: () => {},
26+
log: () => {}
2727
});
2828
// force page reload when html-webpack-plugin template changes
2929
compiler.plugin('compilation', function (compilation) {

build/webpack.dev.conf.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
77
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
88

99
// add hot-reload related code to entry chunks
10-
Object.keys(baseWebpackConfig.entry).forEach((name) => {
10+
Object.keys(baseWebpackConfig.entry).forEach(name => {
1111
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]);
1212
});
1313

1414
module.exports = merge(baseWebpackConfig, {
1515
mode: 'development',
16-
1716
module: {
18-
rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap}),
17+
rules: utils.styleLoaders({sourceMap: config.dev.cssSourceMap})
1918
},
2019
// cheap-module-eval-source-map is faster for development
2120
devtool: '#cheap-module-eval-source-map',
2221
plugins: [
2322
new webpack.DefinePlugin({
24-
'process.env': config.dev.env,
23+
'process.env': config.dev.env
2524
}),
2625
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
2726
new webpack.HotModuleReplacementPlugin(),
@@ -30,8 +29,8 @@ module.exports = merge(baseWebpackConfig, {
3029
new HtmlWebpackPlugin({
3130
filename: 'index.html',
3231
template: 'index.html',
33-
inject: true,
32+
inject: true
3433
}),
35-
new FriendlyErrorsPlugin(),
36-
],
34+
new FriendlyErrorsPlugin()
35+
]
3736
});

build/webpack.prod.conf.js

+20-26
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ const webpackConfig = merge(baseWebpackConfig, {
1515
module: {
1616
rules: utils.styleLoaders({
1717
sourceMap: config.build.productionSourceMap,
18-
extract: true,
19-
}),
18+
extract: true
19+
})
2020
},
2121
devtool: config.build.productionSourceMap ? '#source-map' : false,
2222
output: {
2323
path: config.build.assetsRoot,
2424
publicPath: './',
2525
filename: utils.assetsPath('js/[name].[chunkhash:7].js'),
26-
chunkFilename: utils.assetsPath('js/[name].[chunkhash:7].js'),
26+
chunkFilename: utils.assetsPath('js/[name].[chunkhash:7].js')
2727
},
2828
optimization: {
2929
minimizer: [
@@ -40,13 +40,13 @@ const webpackConfig = merge(baseWebpackConfig, {
4040
// 移除 console
4141
drop_console: true, // eslint-disable-line
4242
// 移除无用的代码
43-
dead_code: true, // eslint-disable-line
43+
dead_code: true // eslint-disable-line
4444
},
4545
ie8: false,
4646
safari10: true,
4747
warnings: false,
48-
toplevel: true,
49-
},
48+
toplevel: true
49+
}
5050
}),
5151
new OptimizeCSSAssetsPlugin({
5252
assetNameRegExp: /\.css$/g,
@@ -65,11 +65,11 @@ const webpackConfig = merge(baseWebpackConfig, {
6565
// 使用postcss的autoprefixer功能
6666
autoprefixer: false,
6767
discardComments: {
68-
removeAll: true,
69-
},
68+
removeAll: true
69+
}
7070
},
71-
canPrint: true,
72-
}),
71+
canPrint: true
72+
})
7373
],
7474
splitChunks: {
7575
chunks: 'all',
@@ -81,30 +81,24 @@ const webpackConfig = merge(baseWebpackConfig, {
8181
automaticNameDelimiter: '~',
8282
cacheGroups: {
8383
default: false,
84-
brace: {
85-
name: 'ace',
86-
test: /[\\/]node_modules[\\/]brace[\\/]/,
87-
enforce: true,
88-
priority: 10,
89-
},
9084
common: {
9185
name: 'vendor',
9286
test: /[\\/]node_modules[\\/]/,
9387
enforce: true,
94-
priority: 9,
95-
},
96-
},
97-
},
88+
priority: 9
89+
}
90+
}
91+
}
9892
},
9993
plugins: [
10094
// http://vuejs.github.io/vue-loader/en/workflow/production.html
10195
new webpack.DefinePlugin({
102-
'process.env': env,
96+
'process.env': env
10397
}),
10498
// extract css into its own file
10599
new MiniCssExtractPlugin({
106100
filename: utils.assetsPath('css/[name].[contenthash:7].css'),
107-
chunkFilename: '[name].css',
101+
chunkFilename: '[name].css'
108102
}),
109103
// generate dist index.html with correct asset hash for caching.
110104
// you can customize output by editing /index.html
@@ -116,14 +110,14 @@ const webpackConfig = merge(baseWebpackConfig, {
116110
minify: {
117111
removeComments: true,
118112
collapseWhitespace: true,
119-
removeAttributeQuotes: true,
113+
removeAttributeQuotes: true
120114
// more options:
121115
// https://github.com/kangax/html-minifier#options-quick-reference
122116
},
123117
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
124-
chunksSortMode: 'dependency',
125-
}),
126-
],
118+
chunksSortMode: 'dependency'
119+
})
120+
]
127121
});
128122

129123
if (config.build.bundleAnalyzerReport) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
"eslint-loader": "^4.0.2",
4343
"eslint-plugin-babel": "^5.3.0",
4444
"express": "^4.14.1",
45-
"extract-text-webpack-plugin": "^3.0.2",
4645
"file-loader": "^6.0.0",
4746
"friendly-errors-webpack-plugin": "^1.3.1",
4847
"html-webpack-plugin": "^3.0.0",
48+
"html-loader":"^1.3.2",
4949
"http-proxy-middleware": "^1.0.4",
5050
"husky": "^4.0.0",
5151
"less": "^3.11.3",

postcss.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
plugins: [require('autoprefixer')],
2+
plugins: [require('autoprefixer')]
33
};

src/mpeditor.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<div class="mpeditor">
2+
<div class="mpe-nav-wrap" eid="nav">
3+
<div class="mpe-nav">
4+
<ul class="mpe-nav-tools mpe_fl">
5+
</ul>
6+
<ul class="mpe-nav-tools mpe_fr">
7+
<li class="mpe-nav-item mpe-nav-text">
8+
<span>编辑器主题</span>
9+
</li>
10+
<li class="mpe-nav-item mpe-nav-select">
11+
<select eid="editorTheme">
12+
<option value="default">default</option>
13+
<option value="solarized">solarized</option>
14+
<option value="monokai">monokai</option>
15+
<option value="twilight">twilight</option>
16+
<option value="material">material</option>
17+
<option value="night">night</option>
18+
<option value="midnight">midnight</option>
19+
</select>
20+
</li>
21+
<li class="mpe-nav-item">
22+
<a href="javascript:void(0)" eid="downloadBtn" title="下载markdown文件">
23+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M683.84 170.666667L853.333333 344.704V789.333333a64 64 0 0 1-64 64H234.666667a64 64 0 0 1-64-64V234.666667a64 64 0 0 1 64-64h449.173333zM320 234.645333L234.666667 234.666667v554.666666l85.333333-0.021333V533.333333h384v255.978667L789.333333 789.333333V370.730667l-85.333333-87.637334V384H320v-149.354667zM640 597.333333H384v191.978667h256V597.333333z m-42.666667 64v64h-170.666666v-64h170.666666z m42.666667-426.666666H384v85.333333h256v-85.333333z" /></svg>
24+
</a>
25+
</li>
26+
<li class="mpe-nav-item">
27+
<a href="javascript:void(0)" eid="pcBtn" title="切换PC视图" >
28+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M661.333333 768v64H362.666667v-64h298.666666z m149.333334-576a64 64 0 0 1 64 64v405.333333a64 64 0 0 1-64 64H213.333333a64 64 0 0 1-64-64V256a64 64 0 0 1 64-64h597.333334z m0 64H213.333333v405.333333h597.333334V256z m-149.333334 170.666667v64H362.666667v-64h298.666666z" /></svg>
29+
</a>
30+
</li>
31+
<li class="mpe-nav-item">
32+
<a href="javascript:void(0)" eid="mobileBtn" title="切换手机视图" style="display:none">
33+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M704 149.333333a64 64 0 0 1 64 64v597.333334a64 64 0 0 1-64 64H320a64 64 0 0 1-64-64V213.333333a64 64 0 0 1 64-64h384z m0 64H320v597.333334h384V213.333333z m-192 469.333334a42.666667 42.666667 0 1 1 0 85.333333 42.666667 42.666667 0 0 1 0-85.333333z m85.333333-437.333334v64h-170.666666v-64h170.666666z" /></svg>
34+
</a>
35+
</li>
36+
37+
<li class="mpe-nav-item">
38+
<a href="javascript:void(0)" eid="copyBtn" title="复制内容">
39+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M746.666667 149.333333a64 64 0 0 1 64 64v181.333334a64 64 0 0 1 64 64v49.664l-64 58.496v-87.573334l-239.104 197.376a95.978667 95.978667 0 0 1-117.632 3.050667l-3.84-2.986667-236.757334-192V800h372.330667l62.805333 64H213.333333a64 64 0 0 1-64-64v-341.333333a64 64 0 0 1 64-64V213.333333a64 64 0 0 1 64-64h469.333334z m126.869333 467.861334l44.928 45.610666-174.08 171.456-105.536-104.106666 44.970667-45.568 60.586666 59.818666 129.130667-127.210666zM746.666667 213.333333H277.333333v240.853334l213.184 172.906666a32 32 0 0 0 37.845334 1.984l2.56-1.92L746.666667 449.109333V213.333333z m-149.333334 192v64H362.666667v-64h234.666666z m64-128v64H362.666667v-64h298.666666z" /></svg>
40+
</a>
41+
</li>
42+
<li class="mpe-nav-item">
43+
<a href="javascript:void(0)" eid="clearBtn" title="清空内容">
44+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M341.013333 394.666667l27.754667 393.450666h271.829333l27.733334-393.450666h64.106666L704.426667 792.618667a64 64 0 0 1-63.829334 59.498666H368.768a64 64 0 0 1-63.829333-59.52L276.885333 394.666667h64.128z m139.306667 19.818666v298.666667h-64v-298.666667h64z m117.013333 0v298.666667h-64v-298.666667h64zM181.333333 288h640v64h-640v-64z m453.482667-106.666667v64h-256v-64h256z" />
45+
</a>
46+
</li>
47+
<li class="mpe-nav-item">
48+
<a href="//github.com/ksky521/mpeditor" target="_blank" title="本项目github" style="width:18px;">
49+
<svg style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2535"><path d="M1.3 525.3c0 223 142.9 412.6 342.1 482.2 26.8 6.8 22.7-12.4 22.7-25.4l0-88.5C211.2 911.8 205 809.2 194.5 792.1c-21.1-35.9-70.7-45-55.9-62.1 35.3-18.2 71.2 4.6 112.9 66.1 30.2 44.6 88.8 37.1 118.7 29.6 6.5-26.8 20.5-50.7 39.6-69.4-160.3-28.5-227.3-126.5-227.3-243 0-56.4 18.6-108.4 55.2-150.3-23.2-69.2 2.2-128.2 5.6-137 66.3-6 135.1 47.4 140.5 51.6 37.7-10.1 80.7-15.6 128.8-15.6 48.4 0 91.6 5.6 129.5 15.8 12.9-9.8 76.8-55.6 138.4-50 3.3 8.8 28.1 66.5 6.3 134.7 37 42 55.8 94.3 55.8 151 0 116.7-67.3 214.8-228.2 243.1 26.9 26.5 43.5 63.3 43.5 104l0 128.4c0.9 10.2 0 20.5 17.2 20.5 202.1-68.1 347.6-259.1 347.6-484.1 0-282.1-228.7-510.7-510.7-510.7C229.9 14.6 1.3 243.2 1.3 525.3z" p-id="2536"></path></svg>
50+
</a>
51+
</li>
52+
</ul>
53+
</div>
54+
</div>
55+
<div class="mpe-wrap">
56+
<div eclass="mpe-col" class="mpe-editor-col mpe-col" data-index=1>
57+
<div class="mpe-editor-wrap">
58+
<textarea eid="editor" class="mpe-editor" type="textarea" placeholder="Your markdown here." style="display: none;height:100%;"></textarea>
59+
</div>
60+
</div>
61+
<div eclass="mpe-col" class="mpe-preview-col mpe-col" data-index=2>
62+
<div class="mpe-preview-wrap mobile" eid="previewContainer">
63+
<div class="mpe-preview" eid="preview"></div>
64+
</div>
65+
</div>
66+
</div>
67+
<div class="mpe-toast" eid="toast">
68+
<i class="mpe-toast-icon"><svg style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="524"><path d="M512 960C264.96 960 64 759.04 64 512S264.96 64 512 64s448 200.96 448 448S759.04 960 512 960zM512 128.288C300.416 128.288 128.288 300.416 128.288 512c0 211.552 172.128 383.712 383.712 383.712 211.552 0 383.712-172.16 383.712-383.712C895.712 300.416 723.552 128.288 512 128.288zM726.976 393.184c-12.544-12.448-32.832-12.32-45.248 0.256l-233.28 235.84-103.264-106.112c-12.352-12.704-32.608-12.928-45.248-0.64-12.672 12.32-12.96 32.608-0.64 45.248l126.016 129.504c0.064 0.096 0.192 0.096 0.256 0.192 0.064 0.064 0.096 0.192 0.16 0.256 2.016 1.984 4.512 3.2 6.88 4.544 1.248 0.672 2.24 1.792 3.52 2.304 3.872 1.6 8 2.4 12.096 2.4 4.064 0 8.128-0.8 11.968-2.336 1.248-0.512 2.208-1.536 3.392-2.176 2.4-1.344 4.896-2.528 6.944-4.544 0.064-0.064 0.096-0.192 0.192-0.256 0.064-0.096 0.16-0.128 0.256-0.192l256.224-259.008C739.648 425.856 739.52 405.6 726.976 393.184z" p-id="525"></path></svg></i>
69+
<p class="mpe-toast-text">已保存</p>
70+
</div>
71+
</div>

0 commit comments

Comments
 (0)