Commit 26d1c5f9 authored by wildfirecode's avatar wildfirecode

1

parent ce070688
...@@ -9,12 +9,20 @@ var serverStart = opts => { ...@@ -9,12 +9,20 @@ var serverStart = opts => {
let webpackConfig = devConfig(opts); let webpackConfig = devConfig(opts);
// 遍历每个entry,加入dev-server client // 遍历每个entry,加入dev-server client
Object.keys(webpackConfig.entry).forEach(function (name) { // Object.keys(webpackConfig.entry).forEach(function (name) {
// let _devServer = `webpack-dev-server/client?http://localhost:${
// opts.devPort
// }`;
// webpackConfig.entry[name] = [_devServer].concat(webpackConfig.entry[name]);
// });
// 遍历每个entry,加入dev-server client
let _devServer = `webpack-dev-server/client?http://localhost:${ let _devServer = `webpack-dev-server/client?http://localhost:${
opts.devPort opts.devPort
}`; }`;
webpackConfig.entry[name] = [_devServer].concat(webpackConfig.entry[name]); webpackConfig.entry = [_devServer].concat(webpackConfig.entry);
});
var compiler = webpack(webpackConfig); var compiler = webpack(webpackConfig);
...@@ -23,20 +31,20 @@ var serverStart = opts => { ...@@ -23,20 +31,20 @@ var serverStart = opts => {
host: '0.0.0.0', host: '0.0.0.0',
watchContentBase: true, watchContentBase: true,
watchOptions: opts.devServerWatchOptions, watchOptions: opts.devServerWatchOptions,
contentBase: `.`, contentBase: '.',
proxy: opts.proxy, proxy: opts.proxy,
after(app) { after(app) {
// 自动打开浏览器 // 自动打开浏览器
if (opts.BUILD_SKIN) { if (opts.BUILD_SKIN) {
opn( opn(
`http://localhost:${opts.devPort}/${opts.BUILD_SKIN}/index.html` path.join(`http://localhost:${opts.devPort}`, opts.BUILD_SKIN, 'index.html')
); );
} }
} }
}; };
WebpackDevServer.addDevServerEntrypoints(webpackConfig, devServerOptions); // WebpackDevServer.addDevServerEntrypoints(webpackConfig, devServerOptions);
const devServer = new WebpackDevServer(compiler, devServerOptions); const devServer = new WebpackDevServer(compiler, devServerOptions);
devServer.listen(opts.devPort, '0.0.0.0', () => { devServer.listen(opts.devPort, '0.0.0.0', () => {
console.log(`Starting server ...`); console.log(`Starting server ...`);
......
...@@ -2,9 +2,10 @@ const path = require('path'); ...@@ -2,9 +2,10 @@ const path = require('path');
module.exports = opts => { module.exports = opts => {
const result = { const result = {
entry: { entry: `./${opts.BUILD_SKIN}/src/Main.ts`,
app: `./${opts.BUILD_SKIN}/src/Main.ts` // entry: {
}, // app: path.join(opts.BUILD_SKIN, '/src/Main.ts')
// },
module: { module: {
rules: [ rules: [
{ {
...@@ -19,7 +20,7 @@ module.exports = opts => { ...@@ -19,7 +20,7 @@ module.exports = opts => {
extensions: ['.tsx', '.ts', '.js'] extensions: ['.tsx', '.ts', '.js']
}, },
output: { output: {
filename: `./output.js`, filename: `./${opts.BUILD_SKIN}/output.js`,
path: __dirname path: __dirname
} }
}; };
......
...@@ -7,13 +7,7 @@ class DuibaGameBuild { ...@@ -7,13 +7,7 @@ class DuibaGameBuild {
constructor(config) { constructor(config) {
let defaults = { let defaults = {
devPort: 8081, devPort: 8081,
devServerWatchOptions: { devServerWatchOptions: {},
ignored: [
'src/**/*.js',
'**/*.md',
'bin-release',
]
},
proxy: { proxy: {
'/ngapi/*': 'http://localhost:3000', '/ngapi/*': 'http://localhost:3000',
'/plugin/*': 'http://localhost:3000', '/plugin/*': 'http://localhost:3000',
......
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