Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内置 html-webpack-plugin #53

Closed
soda-x opened this issue Jan 20, 2016 · 4 comments
Closed

内置 html-webpack-plugin #53

soda-x opened this issue Jan 20, 2016 · 4 comments

Comments

@soda-x
Copy link

soda-x commented Jan 20, 2016

html 文件做为开发时的必要内容,把这个插件集成进来吧

https://www.npmjs.com/package/html-webpack-plugin

@zinkey
Copy link
Member

zinkey commented Jan 20, 2016

现在项目基本都是有自己的 html 作为调试文件,部署后就不用这个文件。另外,现在 html 文件里面不仅是加载 js,css 文件,还有一些自定义配置,比如:

<script>
global.config = {
  host:'',
  user:{}
};
</script>

所以,要是需要就采用直接配置 webpack.config.js 的方式。

@sorrycc
Copy link
Member

sorrycc commented Jan 20, 2016

离线包需要,内置进来吧。使用的时候在 js 里 require('./a.html');

@sorrycc
Copy link
Member

sorrycc commented Jan 20, 2016

- a.html
- a.js
- a.css

支持 html 之后,build 之后的 dist 下的文件就直接可用了。deploy 之类的操作会方便一些。

@sorrycc sorrycc mentioned this issue Jan 27, 2016
11 tasks
@sorrycc
Copy link
Member

sorrycc commented Jan 27, 2016

参考代码:

  var htmlLoader = [
    'file-loader?name=[path][name].[ext]',
    'template-html-loader?' + [
      'raw=true',
      'engine=lodash',
      'version=' + pkg.version,
      'title=' + pkg.name,
      'debug=' + DEBUG
    ].join('&')
  ].join('!');

  {
    test: /\.html$/,
    loader: htmlLoader,
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants