diff --git a/CHANGELOG.md b/CHANGELOG.md index 0efaaf6..24adaab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,8 @@ All notable changes to this project will be documented in this file. See [standa } ``` +- 设置 `packing/config/packing.js` 中的 `templateInjectPosition: false` 来关闭生成网页文件时自动注入 assets 的功能 + ## [2.6.6](https://github.com/packingjs/packing/compare/v2.6.5...v2.6.6) (2018-02-28) diff --git a/package.json b/package.json index 17308f3..c96256f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "license": "MIT", "scripts": { "build": "rimraf dist && babel src -d dist", - "lint": "eslint --fix --quiet \"src/**/*.js\"", + "lint": "eslint --fix --quiet \"src/**/*.js\" \"test/**/*.js\"", "postrelease": "git push && git push origin --tags", "prepare": "npm run build", "release": "standard-version && npm publish", diff --git a/src/config/packing.js b/src/config/packing.js index 07505e3..f869b21 100644 --- a/src/config/packing.js +++ b/src/config/packing.js @@ -63,9 +63,16 @@ export default { // 模版引擎类型,目前支持的类型有[html,pug,ejs,handlebars,smarty,velocity,artTemplate] templateEngine: 'html', + // 模版文件扩展名 templateExtension: '.html', + // 是否往模版中注入 assets [bool | string] + // false: 不注入 + // 'head': 在前注入 + // 'body': 在前注入 + templateInjectPosition: 'body', + // 本地访问的域名,为了调试方便,可能改成my.qunar.com localhost: 'localhost', @@ -141,14 +148,6 @@ export default { // '^/hello': 'http://localhost:3001/123/4.html', }, - // 用于在build中打开模板注释的配置 - // 可选值 - // String: 'html', 'js', 'css';预置对3种代码处理。 - // RegExp: 使用正则来替换注释代码。 - // Function: 接受一个字符串参数,该参数为文件内容,返回处理后的字符串。 - // 参考:https://github.com/LHoin/webpack-uncomment-block - // uncommentPattern: 'html', - // 是否使用GraphQL-mock-server graphqlMockServer: false, diff --git a/src/config/webpack.dll.babel.js b/src/config/webpack.dll.babel.js index 4285234..6628b97 100644 --- a/src/config/webpack.dll.babel.js +++ b/src/config/webpack.dll.babel.js @@ -16,7 +16,7 @@ import pRequire from '../util/require'; */ export default () => { - const { CONTEXT, NODE_ENV } = process.env; + const { CONTEXT } = process.env; const context = CONTEXT || process.cwd(); const { diff --git a/src/config/webpack.serve.babel.js b/src/config/webpack.serve.babel.js index abf3063..5813f5e 100644 --- a/src/config/webpack.serve.babel.js +++ b/src/config/webpack.serve.babel.js @@ -18,7 +18,7 @@ const { port, hot, cssModules, - cssModulesIdentName = '[path][name]__[local]--[hash:base64:5]', + cssModulesIdentName, commonChunks, path: { src, diff --git a/test/cases/html-template-require/config/webpack.build.babel.js b/test/cases/html-template-require/config/webpack.build.babel.js index 85e9efe..5b0bace 100644 --- a/test/cases/html-template-require/config/webpack.build.babel.js +++ b/test/cases/html-template-require/config/webpack.build.babel.js @@ -7,7 +7,7 @@ // import path from 'path'; -export default (webpackConfig/* , program, appConfig */) => { +export default webpackConfig => // webpackConfig.plugins.forEach((plugin) => { // if (plugin.constructor.name === 'PackingTemplatePlugin') { // plugin.options = { @@ -19,5 +19,5 @@ export default (webpackConfig/* , program, appConfig */) => { // }; // } // }); - return webpackConfig; -}; + webpackConfig; + diff --git a/test/cases/html-template/test.serve.js b/test/cases/html-template/test.serve.js index 5cddd42..8be1e48 100644 --- a/test/cases/html-template/test.serve.js +++ b/test/cases/html-template/test.serve.js @@ -2,7 +2,6 @@ import request from 'supertest'; import webpack from 'webpack'; import Express from 'express'; import webpackDevMiddleware from 'webpack-dev-middleware'; -import urlrewrite from 'packing-urlrewrite'; import { middleware } from 'packing-template'; import '../../../src/util/babel-register'; import pRequire from '../../../src/util/require'; @@ -27,13 +26,7 @@ describe('serve', async () => { const compiler = webpack(webpackConfig); const webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, mwOptions); webpackDevMiddlewareInstance.waitUntilValid(async () => { - middleware(app, appConfig, { - // template: path.resolve(__dirname, 'template.html') // , - // inject: 'head', - // favicon: 'xxx.png' - // charset: 'gb2312' - }); - // app.use(urlrewrite(appConfig.rewriteRules)); + middleware(app, appConfig); }); app.use(webpackDevMiddlewareInstance); });