Skip to content

Commit

Permalink
Add preference webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaack committed Sep 8, 2016
1 parent f47e30e commit 5b093a6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 90 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Expand Up @@ -7,7 +7,6 @@
./node_modules/redux
./node_modules/react-redux
./node_modules/react-router
./node_modules/dexie
[libs]
./flow-typed/.*
[options]
2 changes: 1 addition & 1 deletion app/index.js
Expand Up @@ -30,7 +30,7 @@ function setPosition(win, pos) {
x = bx + (dw - pos.width) / 2
y = by + (dh - pos.height) / 2
}
win.setPosition(x, y)
win.setPosition(x|0, y|0)
}

function hideMainWindow() {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -23,7 +23,10 @@
"start": "electron ./app/index.js",
"debug": "electron ./app/index.js --debug",
"test": "node test.js",
"dev_search": "node-sass --watch --output-style compressed --recursive --output app/browser/search/css --source-map true --source-map-contents app/browser/search/scss",
"dev:search": "node-sass --watch --output-style compressed --recursive --output app/browser/search/css --source-map true --source-map-contents app/browser/search/scss",
"dev:pref": "cross-env NODE_ENV=development webpack-dev-server --config ./webpack.config.pref.js --hot --inline",
"build:pref": "cross-env NODE_ENV=production webpack --config ./webpack.config.pref.js -p --progress --profile --colors",
"build:dll": "cross-env NODE_ENV=production webpack --config ./webpack.config.dll.js -p --progress --profile --colors",
"postinstall": "install-app-deps",
"pack": "build --dir",
"dist": "build",
Expand All @@ -41,6 +44,7 @@
"babel-preset-es2016": "^6.11.3",
"babel-preset-react": "^6.11.1",
"babel-runtime": "^6.11.6",
"classnames": "^2.2.5",
"cross-env": "^2.0.0",
"css-loader": "^0.23.1",
"devtron": "^1.3.0",
Expand All @@ -64,6 +68,7 @@
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-hot-loader": "^1.3.0",
"react-mdl": "^1.7.1",
"react-redux": "^4.4.5",
"react-router": "^2.6.1",
"react-router-redux": "^4.0.5",
Expand Down
5 changes: 5 additions & 0 deletions test.js
@@ -0,0 +1,5 @@
/* @flow */

const a: string = 123

a.toLowerCase()
74 changes: 0 additions & 74 deletions webpack.config.bg.js

This file was deleted.

10 changes: 6 additions & 4 deletions webpack.config.dll.js
@@ -1,5 +1,7 @@
var webpack = require('webpack');
var path = require('path');
const webpack = require('webpack');
const path = require('path');

const baseDir = './app/browser/pref'

module.exports = {
entry: {
Expand All @@ -8,12 +10,12 @@ module.exports = {
devtool: '#source-map',
output: {
filename: '[name].dll.js',
path: path.resolve(__dirname, './extension/dist/dll'),
path: path.resolve(__dirname, `${baseDir}/dist/dll`),
library: "[name]"
},
plugins: [
new webpack.DllPlugin({
path: path.resolve(__dirname, './extension/dist/dll/[name]-manifest.json'),
path: path.resolve(__dirname, `${baseDir}/dist/dll/[name]-manifest.json`),
name: "[name]"
}),
new webpack.optimize.UglifyJsPlugin({
Expand Down
18 changes: 9 additions & 9 deletions webpack.config.ui.js → webpack.config.pref.js
Expand Up @@ -25,24 +25,24 @@ if (isDev) {
//生成html上的模块的hash值,但是只包括当前打包的模块,不支持dll文件,不过由于它默认支持ejs模版,因此我们可以通过模版实现。
new HtmlWebpackPlugin({
filename: '../index.html',
template: 'src/index.ejs',
template: 'src/pref/index.ejs',
hash: true,
excludeChunks: ['../bg/bg']
excludeChunks: []
}),
]
}


const baseDir = './app/browser/pref'
module.exports = {
// 需要打包的文件配置
entry: {
app: './src/app.jsx', //通过key value的形式配置了需要打包的文件,
app: './src/pref/app.jsx', //通过key value的形式配置了需要打包的文件,
},
debug: debug,
devtool: devtool,
// 输出文件配置
output: {
path: './extension/dist', // 输出的目录,我们是配置为当前目录下的dist目录
path: `${baseDir}/dist`, // 输出的目录,我们是配置为当前目录下的dist目录
publicPath: 'dist/', // 发布后的服务器或cdn上的路径, 配置这个后webpack-dev-server会自动将html中引用的部署路径自动路由到本地的开发路径上
filename: '[name].bundle.js', // 输出的文件名,[name]就是entry的key
},
Expand Down Expand Up @@ -104,14 +104,14 @@ module.exports = {
// 就彻底不需要每次编译分析第三方库了,节省了编译时间
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require("./extension/dist/dll/vendor-manifest.json")
manifest: require(`${distDir}/dist/dll/vendor-manifest.json`)
}),
].concat(buildPlugins).concat(devPlugins),

target: electron,
// webpack-dev-server配置
// http://webpack.github.io/docs/webpack-dev-server.html#api
devServer: {
contentBase: './extension', //serve 的html的路径
hot: true, //用于react-hot-loader实现热更新(其实我在命令行中已经加上--hot就不是必要的了 )
contentBase: baseDir, //serve 的html的路径
hot: true, //用于 react-hot-loader 实现热更新(其实我在命令行中已经加上--hot就不是必要的了 )
},
}

0 comments on commit 5b093a6

Please sign in to comment.