Webpack发出捆绑

时间:2019-03-08 10:37:59

标签: typescript webpack

我正在尝试在此处创建html5游戏,并认为我可以将webpack添加到组合中-但是我遇到了一些问题。

当我使用npm start运行它时,一切正常。它不是很确定,它指出该包已发出:-/。这里是转储:

pixijs@1.0.0 start C:\Users\foo\Desktop\pixijs
> webpack-dev-server --mode development

i ?wds?: Project is running at http://localhost:8080/
i ?wds?: webpack output is served from /
i ?wdm?: Hash: e4ec780bdd5d19347454
Version: webpack 4.29.6
Time: 1417ms
Built at: 2019-03-08 11:09:37
       Asset     Size  Chunks             Chunk Names
foobundle.js  350 KiB    main  [emitted]  main
Entrypoint main = foobundle.js
[0] multi (webpack)-dev-server/client?http://localhost:8080 ./src/game.ts 40 bytes {main} [built]
[./node_modules/ansi-html/index.js] 4.16 KiB {main} [built]
[./node_modules/events/events.js] 13.3 KiB {main} [built]
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/querystring-es3/index.js] 127 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 8.1 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack-dev-server/node_modules/strip-ansi/index.js] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built]
[./src/game.ts] 276 bytes {main} [built]
[./src/scenes/GameScene.ts] 169 bytes {main} [built]
[./src/scenes/MainMenuScene.ts] 189 bytes {main} [built]
    + 13 hidden modules
i ?wdm?: Compiled successfully.

在一开始,我为foobundle.js命名了包,添加了打字稿文件游戏GameScene和MainMenuScene。

我的webpack.config.js应该向前走了

const path = require('path');

module.exports = {
    entry: './src/game.ts',

    output: {
        path: path.join(__dirname, './dist'),
        filename: 'foobundle.js',
    },

    module: {
        rules: [
            {
                loader: 'ts-loader',
                test: /\.tsx?$/,
                exclude: /node_modules/,
            },
        ]
    },

    resolve: {
        extensions: [".tsx", ".ts", ".js", ".json"]
    },
};

据我所知,应该将typescript与game.ts的入口点一起加载,应该在项目文件夹的dist文件夹中放入foobundle.js。

如果有的话,它应该“捆绑” game.ts对吗?但是捆绑包根本没有创建。

我通过运行npm start的{​​{1}}来运行它。在脚本中,它以package.json

开始

1 个答案:

答案 0 :(得分:1)

webpack-dev-server不会发出任何文件,如果要获取捆绑包文件,则应改用webpack

例如

package.json

"build": "webpack --mode development"